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:
Queue\ShouldBeUnique
(documented here: https://laravel.com/docs/8.x/queues#unique-jobs)
ORQueue\Middleware\WithoutOverlapping
mentioned here: https://laravel.com/docs/8.x/queues#preventing-job-overlapsI 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?
Confirmed locally by attempting to run multiple instances of the same job in a console window.
Implementing the Queue\ShouldBeUnique
interface in the class of my job means that subsequent attempts are ABORTED.
Whereas adding ->withoutOverlapping()
to the end of my job reference in the app\console\kernel.php
file simply prevents it from running simultaneously. It does NOT abort the job if one is already running.