I have a web application which has some quite expensive tasks which should be triggered by the user interface, e.g. “create bills” (in batch), “send notifications” etc.
I’m using the Flowpack Job Queue with Beanstalkd. This works well so far, yet I have one requirement that isn’t covered by the implementation: I need to trace whether a job was (successfully) executed or not. In technical terms, my requirement is as follows:
- The user triggers a job from the frontend.
- The backend triggers a deferred method (e.g. “createBills”) and returns the ID of the job to the frontend.
- The frontend polls very five seconds to check if the job was executed.
- As soon as this is the case, the frontend can show success/continue/offer a download etc…
The easiest way to achieve this would be to have a “Job” model in my application, creating a Job object when the job was triggered, return the UUID and poll for it. At the end of the deferred method, the job’s status is set to “complete”.
But I’m not sure if this could be a general need and possible addition for the Job Queue package. A new annotation
TraceableDefer which basically does the same thing, but within a package:
/** * @Job\TraceableDeferred(queueName="my-queue") */ public function doSomething()
If this annotation is set, a
TraceableDeferredJobException containing the messageId is thrown when this method is called. At the same time the job is stored in the DB and marked as executed at the end of the method (using AOP)?
And maybe we have a little REST-like API to call if a job is still queued or was executed.
What’s your opinion on this? Thanks for sharing.