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.

Scalable
  • 1,550
  • 4
  • 16
  • 29
  • Run multiple `queue:work` processes. – Brian Lee Jul 14 '18 at 05: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. – Scalable Jul 16 '18 at 13:12

1 Answers1

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.

Brian Lee
  • 17,904
  • 3
  • 41
  • 52
  • 1
    Jobs are created as configured, but listener is connection default connection, how to make connection dynamic for listener ? – Riz Dec 07 '21 at 14:47