Reputation: 23001
I am using Laravel 4.2 and IronMQ2. For some reason, it's randomly sending jobs twice. In my mailer, I have:
Queue::push('MailController@fire', ['email' => $email, 'subject' => $subject, 'view' => $view, 'data' => $data, 'attachment' => $attachment]);
I can tell it's sending multiple times by logging inside of my MailController, right above the $job->delete()
call:
[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 [] []
As you can see, it's not all jobs, and the ones that are duplicated are done in the same second. Is there a way I can prevent this from happening? It's causing emails to go out multiple times.
Upvotes: -5
Views: 163
Reputation: 26
One of the options is to move to IronMQ V3. This is updated queue with stability and performance enhancements.
Since IronMQ v2 is hardcoded in Laravel 4.2 you need to do the following:
mq-aws-us-east-1-1.iron.io
instead of mq-aws-us-east-1.iron.io
(mq-aws-eu-west-1-1.iron.io
instead of mq-aws-eu-west-1.iron.io
);vendor\laravel\framework\src\Illuminate\Queue
directory replace the IronQueue.php
, IronJob.php
and IronConnector.php
files with shared by me:Upvotes: 1