0

We have multiple jobs in our laravel application. Currently all jobs are queued at once and they execute one by one. I want this particular job to execute at low priority it means if anyother job comes after that job should be execute first.

BulkPdfPrintLabel::withChain([
                    new MergeLabel($filepath, $manifest_id, $last, $user_id, $user_type)
                ])->dispatch($consignments, $last, $manifest_id, $user_id, $user_type, $filepath);
Bilal Arshad
  • 531
  • 3
  • 11
  • 33

1 Answers1

0

use this code instead:

// This job is sent to the default queue that you selected in config/app file
BulkPdfPrintLabel::withChain([
                    new MergeLabel($filepath, $manifest_id, $last, $user_id, $user_type)])
          ->dispatch($consignments, $last, $manifest_id, $user_id, $user_type, $filepath);

update

// This job is sent to the "low" queue.("low" is custom and you can change it)
BulkPdfPrintLabel::withChain([
                    new MergeLabel($filepath, $manifest_id, $last, $user_id, $user_type)->onQueue("low")
                ])
        ->dispatch($consignments, $last, $manifest_id, $user_id, $user_type, $filepath);

then run this command to set high priority to your default queue:

php artisan queue:work --queue=high,default

reference laravel queue

Babak Asadzadeh
  • 1,207
  • 1
  • 11
  • 21
  • i am using supervisor on live server which is running ```php artisan queue:work``` do i need to replace it with ```php artisan queue:work --queue=high,default``` – Bilal Arshad Oct 13 '20 at 06:24
  • giving this error ```Call to undefined method Illuminate\Foundation\Bus\PendingChain::onQueue()``` – Bilal Arshad Oct 13 '20 at 06:51