Reputation: 509
I am using laravel 5.1 and i am using the dispatch method to push the job onto the queue. But there are two kind of jobs and i have created and two queues for that in sqs. How should i achieve this?
Upvotes: 9
Views: 15967
Reputation: 1169
I'd suggest this:
app('queue')->connection('connection_name')->pushOn('queue_name', $job);
From here: In Laravel how to create a queue object and set their connection without Facade
Upvotes: 2
Reputation: 201
This worked for me.
//code to be used in the controller (taken from @jedrzej.kurylo above)
$job = (new SendReminderEmail($user))->onQueue('emails');
$this->dispatch($job);
I think this dispatches the job on to the queue named "emails". To execute the job dispatched on 'emails' queue:
//Run this command in a new terminal window
php artisan queue:listen --queue=emails
Upvotes: 8
Reputation: 40899
In order to specify the queue you need to call onQueue() method on your job object, e.g.:
$job = (new SendReminderEmail($user))->onQueue('emails');
$this->dispatch($job);
If you want to send the job to a connection other than default, you need to do fetch connection manually and send the job there:
$connection = Queue::connection('connection_name');
$connection->pushOn('queue_name', $job)
Upvotes: 12