Question

I am trying to set an IronMq queue with Laravel, and I have it working already, but the point is that the behavior is not the desired one.

I expect IronMq to wait until a job is complete ($job->delete()) to push a new one, but I found out that it pushes messages before the previous one is finished.

The code is structured as follows:

Route::post('queue/send' ,function() 
{
    ...
    Queue::push(function($job) use ($data)
    {
        ...
        $job->delete();
    }
    return true;
}

Has anyone found out the way to prevent the parallel behavior and make it sequential?

Thank you very much!

Was it helpful?

Solution 3

Thank you for your answers, I decided to use Beanstalkd instead of IronMQ.

It's much messier, but it provides with the desired functionality and I am not depending on no one.

OTHER TIPS

Push queues will naturally continue to push messages regardless of whether or not the job is done as they are 2 independent systems. Secondly, the purpose of utilizing a push queue is for it to be as realtime as possible.

IronMQ specifically has retries which, as it sounds, will retry pushing the message to the desired endpoint X number of times(which you set) in designated intervals (which you set) - hopefully this will help solve your problems.

If you desire that a job only be processed once the previous has been completed, and a slight delay is acceptable, then I'd recommend polling the queue and retrieving in batches.

Also you could try to use IronMQ class instead of laravel Queue class:

$ironmq = new \IronMQ(array(
    'token' => Config::get('queue.connections.iron.token', 'xxx'),
    'project_id' => Config::get('queue.connections.iron.project', 'xxx')
));
$ironmq->postMessage($queue_name, "Hello world");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top