IronQueue 发送作业两次
IronQueue sending jobs twice
我正在使用 Laravel 4.2 和 IronMQ2。出于某种原因,它随机发送作业两次。在我的邮件中,我有:
Queue::push('MailController@fire', ['email' => $email, 'subject' => $subject, 'view' => $view, 'data' => $data, 'attachment' => $attachment]);
我可以通过在 $job->delete()
调用上方登录我的 MailController 来判断它发送了多次:
[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 [] []
如您所见,并不是所有的工作,重复的工作都是在同一秒内完成的。有什么办法可以防止这种情况发生吗?它导致电子邮件多次发出。
其中一个选项是迁移到 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.io
(mq-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.php
、IronJob.php
和 IronConnector.php
文件替换为我共享的文件:
https://onedrive.live.com/redir?resid=4DBE0885AEDA52FD!106&authkey=!AIr18HPOvqv6DE4&ithint=file%2czip
我正在使用 Laravel 4.2 和 IronMQ2。出于某种原因,它随机发送作业两次。在我的邮件中,我有:
Queue::push('MailController@fire', ['email' => $email, 'subject' => $subject, 'view' => $view, 'data' => $data, 'attachment' => $attachment]);
我可以通过在 $job->delete()
调用上方登录我的 MailController 来判断它发送了多次:
[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 [] []
如您所见,并不是所有的工作,重复的工作都是在同一秒内完成的。有什么办法可以防止这种情况发生吗?它导致电子邮件多次发出。
其中一个选项是迁移到 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.io
(mq-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.php
、IronJob.php
和IronConnector.php
文件替换为我共享的文件:
https://onedrive.live.com/redir?resid=4DBE0885AEDA52FD!106&authkey=!AIr18HPOvqv6DE4&ithint=file%2czip