tronix
380
1
Laravel

Laravel uses the default queue even if I specified a different queue/tube

Posted 3 years ago by tronix

I'm using Laravel 5.0.2. I need to use two different queues in my code. They must use the beanstalkd driver. So I specified those queues in config/queue.php:

    'default' => env('QUEUE_DRIVER', 'sync'),
    'connections' => [

        'sync' => [
            'driver' => 'sync',
        ],

        'bean-high'  => [
                'driver' => 'beanstalkd',
                'host'   => '127.0.0.1',
                'queue'  => 'bean-high',
                'ttr'    => 60,
        ],

        'bean-low'  => [
                'driver' => 'beanstalkd',
                'host'   => '127.0.0.1',
                'queue'  => 'bean-low',
                'ttr'    => 60,
        ],
[...]

In my code, I used:

Queue::pushOn('bean-low', new SendEmail($message )); 

My listener is:

php artisan queue:work --daemon --queue="bean-high","bean-low" --tries=3 --env="production"

My actual environment is "production".

It seems ok, but Laravel uses always the default queue (the "sync" driver) even if I specified a different queue. I tried to change the default driver to a fake one and I've seen that it uses this driver (throwing an exception).

If I specify the "bean-high" or "bean-low" connection as the default driver in the queue.php file, my queues works correctly, but the queue/tube parameter in "Queue::pushOn" is always skipped.

What am I doing wrong?

Please sign in or create an account to participate in this conversation.