1

I have a queue that runs from a cron tab and I'd like to know immediately if it ever fails. Is there an event that fires or any other kind of way to hook into the queue behavior in a module when it runs/completes/fails a job?

This is specifically a Feed Me queue that I'm talking about, but I'm looking for any kind of help with catching completed/failed queue jobs even if it's not Feed Me specific.

1 Answer 1

2

I don't believe there are any events triggered by queue jobs that you can listen for. Feed Me does have an event called afterProcessFeed (more on that here) that's triggered after a feed is processed (i.e. all feed items are completed), but that won't be triggered if the Feed Me queue job fails for some reason.

If you're worried about a queue job timing out and failing, there are techniques to handle queue jobs running out of memory or execution time and failing. PutYourLightsOn's excellent Campaign plugin takes pains to handle this by allocating as much memory as possible and monitoring both memory and timeout values during the queue job. If the values are exceeded (i.e. the job is about to fail), a new job is scheduled to take over after a delay.

You can check out how this is done in the Campaign SendoutJob class here. I must credit PYLO's Ben Croker for pointing me in the direction of his code when I was asking similar questions about handling queue job failures.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.