IronQueue两次发送工作

时间:2016-03-22 13:28:21

标签: laravel-4.2 ironmq

我使用的是Laravel 4.2和IronMQ2。出于某种原因,它会随机发送两次作业。在我的邮件中,我有:

Queue::push('MailController@fire', ['email' => $email, 'subject' => $subject, 'view' => $view, 'data' => $data, 'attachment' => $attachment]);

我可以通过登录我的MailController,在$job->delete()电话正上方告诉它发送多次:

[2016-03-22 06:08:02] production.INFO: [MAIL LOGGING] Logging for job 6264815783870079319 [] [] - Duplicate 1
[2016-03-22 06:08:02] production.INFO: [MAIL LOGGING] Logging for job 6264815783870079319 [] [] - Duplicate 1
[2016-03-22 06:08:03] production.INFO: [MAIL LOGGING] Logging for job 6264815783870079316 [] [] - Duplicate 2
[2016-03-22 06:08:03] production.INFO: [MAIL LOGGING] Finish job for 6264815783870079319  [] [] - End duplicate 1
[2016-03-22 06:08:03] production.INFO: [MAIL LOGGING] Logging for job 6264815783870079316 [] [] - Duplicate 3
[2016-03-22 06:08:03] production.INFO: [MAIL LOGGING] Finish job for 6264815783870079316  [] [] - End duplicate 2
[2016-03-22 06:08:04] production.INFO: [MAIL LOGGING] Finish job for 6264815783870079316  [] [] - End duplicate 3
[2016-03-22 06:12:47] production.INFO: [MAIL LOGGING] Logging for job 6264815783870079319 [] [] - Duplicate 1
[2016-03-22 06:12:48] production.INFO: [MAIL LOGGING] Finish job for 6264815783870079319  [] [] - End duplicate 1
[2016-03-22 06:48:52] production.INFO: [MAIL LOGGING] Logging for job 6264826778986309904 [] [] - Duplicate 4
[2016-03-22 06:48:52] production.INFO: [MAIL LOGGING] Logging for job 6264826778986309904 [] [] - Duplicate 4
[2016-03-22 06:48:52] production.INFO: [MAIL LOGGING] Logging for job 6264826778986309902 [] [] - Duplicate 5
[2016-03-22 06:48:53] production.INFO: [MAIL LOGGING] Finish job for 6264826778986309902  [] [] - End Duplicate 5
[2016-03-22 06:48:53] production.INFO: [MAIL LOGGING] Finish job for 6264826778986309904  [] [] - End duplicate 4
[2016-03-22 07:54:12] production.INFO: [MAIL LOGGING] Logging for job 6264843610963505825 [] [] - Not duplicated
[2016-03-22 07:54:12] production.INFO: [MAIL LOGGING] Logging for job 6264843142812137221 [] [] - Not duplicated
[2016-03-22 07:54:12] production.INFO: [MAIL LOGGING] Finish job for 6264843610963505825  [] []
[2016-03-22 07:54:13] production.INFO: [MAIL LOGGING] Finish job for 6264843142812137221  [] []

正如您所看到的,它不是所有工作,而复制的工作则在同一秒内完成。有没有办法阻止这种情况发生?它导致电子邮件多次出现。

1 个答案:

答案 0 :(得分:0)

其中一个选择是迁移到IronMQ V3。这是一个更新的队列,具有稳定性和性能增强功能。

由于IronMQ v2在Laravel 4.2中是硬编码的,因此您需要执行以下操作:

  • 更新composer.json中的IronMQ版本:“iron-io / iron_mq”:“4。*”;
  • 在app / config / queue.php中更新主机,即 mq-aws-us-east-1-1.iron.io代替mq-aws-us-east-1.iron.iomq-aws-eu-west-1-1.iron.io代替mq-aws-eu-west-1.iron.io);
  • 将push_queue迁移到适当的V3群集(us-east或eu-west);
  • vendor\laravel\framework\src\Illuminate\Queue目录中替换我共享的IronQueue.phpIronJob.phpIronConnector.php文件:
    https://onedrive.live.com/redir?resid=4DBE0885AEDA52FD!106&authkey=!AIr18HPOvqv6DE4&ithint=file%2czip