Sam*_*ikh 7 php queue laravel laravel-5 laravel-5.1
我正在使用laravel 5.1 ,我正在使用调度方法将作业推送到队列中.但有两种工作,我已经创建了两个队列,并在sqs中有两个队列.我该怎么做到这一点?
jed*_*ylo 10
要指定队列,需要在作业对象上调用onQueue()方法,例如:
$job = (new SendReminderEmail($user))->onQueue('emails');
$this->dispatch($job);
Run Code Online (Sandbox Code Playgroud)
如果要将作业发送到默认以外的连接,则需要手动获取连接并在那里发送作业:
$connection = Queue::connection('connection_name');
$connection->pushOn('queue_name', $job)
Run Code Online (Sandbox Code Playgroud)
这对我有用.
//code to be used in the controller (taken from @jedrzej.kurylo above)
$job = (new SendReminderEmail($user))->onQueue('emails');
$this->dispatch($job);
Run Code Online (Sandbox Code Playgroud)
我认为这会将作业发送到名为"emails"的队列.要执行在"电子邮件"队列中分派的作业:
//Run this command in a new terminal window
php artisan queue:listen --queue=emails
Run Code Online (Sandbox Code Playgroud)