PHP code example of balkar / laravel-priority-queue-manager
1. Go to this page and download the library: Download balkar/laravel-priority-queue-manager library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
balkar / laravel-priority-queue-manager example snippets
dispatch(new SendOTP($user))->onQueue('high');
php artisan queue:work --queue=high,low
use Balkar\PriorityQueue\Facades\Priority;
Priority::critical(new SendOTPJob($user));
Priority::high(new SendInvoiceJob($order));
Priority::normal(new SendWelcomeEmail($user));
Priority::low(new SendNewsletterJob($batch));
// config/priority-queue.php
return [
'priorities' => [
'critical' => ['retry_after' => 30, 'tries' => 5],
'high' => ['retry_after' => 60, 'tries' => 4],
'normal' => ['retry_after' => 90, 'tries' => 3],
'low' => ['retry_after' => 300, 'tries' => 2],
],
];
return [
'priorities' => [
'critical' => ['retry_after' => 30, 'tries' => 5],
'high' => ['retry_after' => 60, 'tries' => 4],
'normal' => ['retry_after' => 90, 'tries' => 3],
'low' => ['retry_after' => 300, 'tries' => 2],
],
];
use Balkar\PriorityQueue\Facades\Priority;
Priority::critical(new SendOTPJob($user));
Priority::high(new SendInvoiceJob($order));
Priority::normal(new SendWelcomeEmail($user));
Priority::low(new SendNewsletterJob($batch));
// triggered by exam update — needs to run immediately
Priority::critical(new RecalculateStudentGrade($student, $exam));
// nightly bulk export — can wait
Priority::low(new GenerateBulkReportJob($cohort));
bash
php artisan queue:priority-status
bash
php artisan vendor:publish --tag=priority-queue-config
bash
php artisan queue:work --queue=critical,high,normal,low
bash
php artisan queue:priority-status