2

Using laravel 5.5, we need to use both Redis and SQS queues. Redis for our internal messaging and SQS for messages coming from a 3rd party.

config/queue.php has various connection information. The first key is the default connection. That default is the one used by queue:work artisan command.

'default' => 'redis',

'connections' => [
    'sqs' => [            
        'driver' => 'sqs',
        'key'    => env('ACCESS_KEY_ID', ''),
        'secret' => env('SECRET_ACCESS_KEY', ''),
        'prefix' => 'https://sqs.us-west-1.amazonaws.com/account-id/',
        'queue'  => 'my-sqs-que'),
        'region' => 'us-west-1',
    ],


    'redis' => [
        'driver' => 'redis',
        'connection' => 'default',
        'queue' => env('REDIS_QUE' , 'default'),
        'retry_after' => 90,
    ],

The question is how can we use different queue connection for queue:work.

If --queue=my-sqs-que is supplied, with default connection set to redis, laravel looks under redis and obviously does not find my-sqs-que

Setting default to sqs will disable processing our internal messages.

2
  • Run multiple queue:work processes. Commented Jul 14, 2018 at 5:50
  • Running multiple processes still does not solve the problem. [at least within a single environment]. Each queue:work process still use default connection so we are still tied with either sqs or redis. Commented Jul 16, 2018 at 13:12

1 Answer 1

2

You can specify the connection when running queue:work, see Specifying the Connection and Queue:

You may also specify which queue connection the worker should utilize. The connection name passed to the work command should correspond to one of the connections defined in your config/queue.php configuration file:

php artisan queue:work redis

You will need to setup the corresponding connections per queue, as well.

However, any given queue connection may have multiple "queues" which may be thought of as different stacks or piles of queued jobs.

Sign up to request clarification or add additional context in comments.

1 Comment

Jobs are created as configured, but listener is connection default connection, how to make connection dynamic for listener ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.