Question

This is the situation:

I have a Laravel 4 app with Iron mq installed in order to speed up the process. It is possible to book a car and to register in the site. In both cases a mail is sent. The problem is that after installing Iron mq the mail are not sent anymore. All the rest is done, inserting data in the database, but the mails sending no. In Iron mq dashboard the queues are instead regularly received and apparently fired..

This is the route:

 /*  CARS  */

Route::get('focus', function()
 {
return View::make('iframe');
 });
Route::post('focus', 'RegistrationsController@booking');


Route::get('sharan', function()
{
return View::make('iframe2');
 });


Route::get('passat', function()
{
return View::make('iframe5');
});

// Route::post('passat', 'RegistrationsController@booking');

 Route::post('passat', function()
 {
return Queue::marshal();    
 });

/*  USER REGISTRATION */

Route::get('register', 'HomeController@getRegister');
Route::post('register', 'HomeController@postRegister');

Right now the process of book a car is faster, from 8/9 sec to 3 sec. It means that Iron is working. Though is strange that i had make the Queue::marshall() for only one of the post route, and it works for all three.. The user registration is also faster, without any queue::marshall() But the point is that in the both cases no email is sent.

This is the mail sending code:

 return \Mail::queue($this->view, $this->data, function($message) use($self)
{
   $message->to($self->email, $self->to)->subject($self->subject);

});

With Mail::send it works (but terribly slow), with Mail::queue is faster but the email is not sent.

The main questions are:

Why the mail are not sent? The SMTP settings should not change, right?

What is the proper place for Queue::marshall() ? If for the POST of the registration i must call the proper method Route::post('register', 'HomeController@postRegister'); Then, where i have to put the Queue::marshall() ? Is possible to make a double route? Call the method and make Queue::marshall?

Thank you very much! Already for a previous site had the same problems and never resolve.

Was it helpful?

Solution

The objective of this marshal call is just to make your application process your queues jobs. So, create a separate route for your marshal, it will be used only by Iron:

Route::post('queues/marshal', function()
{
    return Queue::marshal();    
});

Then you just have to subscribe your marshal url in your Iron queue:

http://yoursite.com/queues/marshal
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top