Reputation: 10828
I have Lumen setup for a Private API. Laravel internally makes an API request to Lumen and then Lumen will queue a job (Amazon SQS).
How would you respond back to Laravel when the queue job has been completed or failed? If the queue worker is unable to communicate back to Laravel app for whatever reason, it will need to try again later somehow.
I have attached the system architecture diagram. My question is about the red dotted line as you can you see.
Upvotes: 2
Views: 543
Reputation: 563
First create a new job called NotifyLaravel
with any paramaters you need (Job ID, Task ID, User ID, etc).
Once your Job in the queue is done, you can dispatch(new NotifyLaravel($jobId))
right after it's done.
The job of this job (pun intended) is to simply ping Laravel to indicate that the Queue has finished running this specific job. I won't give an example implementation, but basically you can create a shared secret between Lumen and Laravel to "authenticate" the request. Lumen then simply sends the Job ID or the identifier you use to track them.
If your Laravel instance is offline, you can simply throw an exception. The queue worker will retry later. The latter is explained in the documentation (https://laravel.com/docs/5.4/queues#job-expirations-and-timeouts).
Upvotes: 1