Laravel Use different queues to submit jobs

I am using laravel 5.1 and I am using the submit method to submit the job to the queue. But there are two types of jobs, and I created two queues for them in sqs . How should I achieve this?

+4
source share
3 answers

It 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 sends the job to a queue named "emails". To complete a job sent to the emails queue:

//Run this command in a new terminal window
php artisan queue:listen --queue=emails
+4
source

, onQueue() , :

$job = (new SendReminderEmail($user))->onQueue('emails');
$this->dispatch($job);

, , :

$connection = Queue::connection('connection_name');
$connection->pushOn('queue_name', $job)
+7

I would suggest the following:

app('queue')->connection('connection_name')->pushOn('queue_name', $job);

From here: In Laravel, how to create a queue object and establish their connection without Facade

+1
source

Source: https://habr.com/ru/post/1623411/


All Articles