I have a job that is somehow getting kicked off multiple times. I want the job to kick off once and only once. If any other attempts to run the job while it’s already on the queue, I want those runs to ABORT.
I’ve read the Laravel 8 documentation and can’t figure out if I should use:
QueueShouldBeUnique(documented here: https://laravel.com/docs/8.x/queues#unique-jobs)
mentioned here: https://laravel.com/docs/8.x/queues#preventing-job-overlaps
I believe the first one aborts subsequent attempts to run the job whereas the second keeps it queued, just makes sure it doesn’t run until the first job is finished. Can anyone confirm?
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Confirmed locally by attempting to run multiple instances of the same job in a console window.
QueueShouldBeUnique interface in the class of my job means that subsequent attempts are ABORTED.
->withoutOverlapping() to the end of my job reference in the
appconsolekernel.php file simply prevents it from running simultaneously. It does NOT abort the job if one is already running.