Laravel 5.5 - Setting The Queue On A Scheduled Job

 ;TLDR

When using Laravel, and you would like to push a scheduled job onto a specific queue, pass the queue as a second parameter in the scheduled job request:

queue-scheduled-job.png

 

protected function schedule(Schedule $schedule)
{

$schedule->command('horizon:snapshot')->everyFiveMinutes();
$schedule->job(new PopulateCustomerSurveys,'external-api')->dailyAt('04:00');
$schedule->job(new PopulateConsumerSurveys,'external-api')->dailyAt('04:05');
$schedule->job(new PopulateCustomerSurveyResponses,'external-api')->hourlyAt('10');
$schedule->job(new PopulateConsumerSurveyResponses,'external-api')->hourlyAt('32');
}

Background

In trying to build for the future, I am creating multiple queues. Right now, I have a “default” queue, and an “external-api” queue. In the future, I could see adding a “notification-email” queue / “notification-sms”, etc, etc…but right now it’s important to be able to specify the queue I want to run it on. 

Turns out there was a recent addition to Laravel 5.5 that allows this (woot).

Link to EXACT THING ON GITHUB