我使用的是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 [] []
正如您所看到的,它不是所有工作,而复制的工作则在同一秒内完成。有没有办法阻止这种情况发生?它导致电子邮件多次出现。
答案 0 :(得分:0)
其中一个选择是迁移到IronMQ V3。这是一个更新的队列,具有稳定性和性能增强功能。
由于IronMQ v2在Laravel 4.2中是硬编码的,因此您需要执行以下操作:
mq-aws-us-east-1-1.iron.io
代替mq-aws-us-east-1.iron.io
(mq-aws-eu-west-1-1.iron.io
代替mq-aws-eu-west-1.iron.io
); vendor\laravel\framework\src\Illuminate\Queue
目录中替换我共享的IronQueue.php
,IronJob.php
和IronConnector.php
文件: