After digging a little bit in the source code if figured out how to do it. In the QueueInterface there is the specification of the interface : /** * Push a new job onto the queue. * * @param string $job * @param mixed $data * @param string $queue * @return mixed */ public function push($job, $data = '', $queue = null);
So by the third parameter- which is not mentioned in the documentation - we could push to a specific queue.
and in the queue' configuration file we should add multiple declaration for the specific queue
for example redis
'redis' => array( 'driver' => 'redis', 'queue' => 'high', ),
'redis' => array( 'driver' => 'redis', 'queue' => 'low', ),
'redis' => array( 'driver' => 'redis', 'queue' => 'ultimate', ),
this 'low,high,ultimate' is what we specify in the third parameter of the push function.
finally we lunch the command : php artisan queue:listen --queue=low,hight,ultimate
so it will pick the jobs by their priority
hope it will help someone in the future.
mouradghafiri it just helped me! I came here to search on queue prioritisation, because I want to be able to prioritize creating PDF invoices before sending newsletter, so your post just helped me a lot! Thank you!
Sign in to participate in this thread!
We'd like to thank these amazing companies for supporting us
The Laravel portal for problem solving, knowledge sharing and community building.