laravelqueuejobsironmq

Confusions about Laravel Queues


I am using Laravel Queues and I am using IronMQ for it. But I have little bit confusion about how this process.

I have set my default connection in queue.php as 'default' => 'iron' and also set iron settings in same file.

Now I use

 $this->dispatch(new createEvents($data, $user));

while createEvents class is a job class created as explained in Laravel tutorial. Now when following code is executed

$this->dispatch(new createEvents($data, $user));

It successfully creates a queue in my ironmQ account under project.

Now here is my confusion starts. I have queued some task to that queue but now how will I run that queue? How will I run the task that is queued? Do I need to create some extra code for it or Do I need to do some settings for it. Please guide


Solution

  • You don't need to go to your server and run this command by hand, you need to have process that will keep running, and perform those jobs.

    I would recomment "supervisord" http://supervisord.org/

    This programs is for launching a script and keep it running, even if it fails, it will relaunch it(until certain amount of failures of course)

    After you install it, you should probably create this supervisor task file:

    [program:queue]
    command=php artisan queue:listen --tries=3 --env=your_environment
    directory=/path/to/laravel
    stdout_logfile=/path/to/laravel/app/storage/logs/supervisord.log
    redirect_stderr=true
    autostart=true
    autorestart=true