0
votes

I have always used the sync queue driver and had some long running jobs in my scheduler (up to an hour):

$schedule->job(new ProcessFileUploads())->everyMinute()->withoutOverlapping(60);

The withoutOverlapping worked fine when in sync mode, but now I have changed the driver to QUEUE_DRIVER=database and the job gets written to the DB jobs table every minute, even though the old job might still be running.

How am I supposed to handle this case?

1
Which server using? - sadaiMudiNaadhar
@sadaiMudiNaadhar Azure WebApp - Chris
Did you encountered any problem in your usual job execution? - sadaiMudiNaadhar
@sadaiMudiNaadhar You mean, when using the sync driver? Everything worked fine with it. But I now need to use the database driver. - Chris
No am asking did you changed driver to database & followed steps in Laravel doc? After this configuration did you got any issue? - sadaiMudiNaadhar

1 Answers

1
votes

Alternate way

Create a command file https://laravel.com/docs/5.7/artisan#generating-commands

Then include the command class inside app\Console\Kernel.php

$schedule->command('Process:FileUploads')->withoutOverlapping(60);

In your command file inside handle()

   /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {

        dispatch(new ProcessFileUploads());

    }

This is a good way to work with jobs & Schedulers

You can make use of https://laravel.com/docs/5.7/queues#job-events for tracking your job activities