我正在将Laravel 5.4与SQS Fifo队列一起使用。
我似乎无法使其与SQS Fifo Queue一起使用。排队我的电子邮件作业。
任何有此经验的人都可以向我指出如何使laravel与SQS Fifo Queue一起使用的正确方向。
这是我的控制器代码,用于将作业添加到队列中:
(new ReferFriendEmail($referFriendObj))->onConnection('my_sqs_fifo');
这是我的工作代码:
class ReferFriendEmail implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $referFriendObj = false;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct($referFriendObj)
{
$this->referFriendObj = $referFriendObj;
}
/**
* Execute the job.
*
* @return void
*/
public function handle( )
{
$input = $this->referFriendObj->input;
Mail::send( 'emails.refer-a-friend',
[
'user' => $this->referFriendObj->from_user_info,
'first_name' => strtoupper( trim( $this->referFriendObj->from_user_info->first_name)),
'unique_link' => $this->referFriendObj->unique_link,
],
function ($m) use ( $input ) {
$m->from('[email protected]', 'Kuflink');
$m->to($input['to_email'], $input['to_email'] )->subject( "You've been referred to Kuflink by " . $input['first_name'] );
}
);
Email_user_referrer::where('email' , $input['to_email'])
->update(['flag_email_sent' => 1]);
}
}
似乎一切都没有进展。我将其用作驱动程序。
根据评论,您正在创建作业,但实际上并没有发送它。该dispatch
助手可以实现这个要求:
$job = (new ReferFriendEmail($referFriendObj))->onConnection('my_sqs_fifo');
dispatch($job);
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句