tjsherrill's avatar

How can I return data from a queue job?

My app uses a third-party CRM called Active Campaign. The integration is via API and I run it synchronously. The reason I run it this way is that oftentimes I need something from the response. An example would be adding someone new to the CRM that just signed up in the app, the response is the Contact ID which I then save on the user db record. Other times I am adding info to their profile in the CRM that may trigger an automated email or something.

My issue is that sometimes the Active Campaign API returns a 503. I have talked to their techs and they recommended moving the integration to a Queue. while I know how to do this, it is not obvious to me how to get and use the response from the API when I am calling it from a queue job.

Any thoughts on how to architect this so that I can use the response? TIA

0 likes
3 replies
sr57's avatar

@tjsherrill

In 2 times, since there is no more request data.

-1- create a record in the db and dispatch the job with an id of this record

-2- at the end of the job, update this record with the data received

tjsherrill's avatar

@sr57 thanks for the idea. based on my understanding of your idea: once I update the db record, after queue runs, then how do I track that back to say the user record?

thanks

sr57's avatar

@tjsherrill

You have toput all the data you need during the step 1 (record creation)

Please or to participate in this conversation.