如何在Lumen中使用多个SQS(队列服务)实例?

I wanted to push messages to multiple SQS queues parallel or one after another, but it should be dynamic and when I start the worker it should fetch the messages from both the queues and differentiate.
How can I achieve this in Lumen?
UPDATE
How to use multiple worker for different queues with different amazon SQS instances?

As far as I can see Lumen and Laravel use the exact same code to handle queues so here's something that might work, though I haven't tested it.

Run the queue worker as:

 php artisan queue:work --queue=queue1,queue2 

This will mean that jobs in queue1 are processed before jobs in queue2 (unfortunately this is the only way to listen to multiple queues)

Then in your job:

class MyJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;


   public function handle()
   {
       if ($this->job->getQueue() === 'queue1') {
          //Things
       } else {
          // different things
       }
   }

If you need to use multiple connections you can't do that using a single worker, however you can use multiple workers at a time. First configure your connections e.g. in your config/queue.php

'connections' => [
      'sqs' => [
        'driver' => 'sqs',
        'key' => 'your-public-key',
        'secret' => 'your-secret-key',
        'prefix' => 'https://sqs.us-east-1.amazonaws.com/your-account-id',
        'queue' => 'your-queue-name',
        'region' => 'us-east-1',
    ],
    'sqs2' => [
        'driver' => 'sqs',
        'key' => 'your-other-public-key',
        'secret' => 'your-other-secret-key',
        'prefix' => 'https://sqs.us-east-1.amazonaws.com/your-other-account-id',
        'queue' => 'your-other-queue-name',
        'region' => 'us-east-1',
    ],
]

If you're using supervisor then setup your supervisor configuration, if not you'll have to start both workers manually. Here's a supervisor configuration you can use:

[program:laravel-sqs-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /home/forge/app.com/artisan queue:work sqs --queue=queue1
autostart=true
autorestart=true
user=www-data 
numprocs=1
redirect_stderr=true
stdout_logfile=/home/forge/app.com/worker.log

[program:laravel-sqs2-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /home/forge/app.com/artisan queue:work sqs2 --queue=queue2
autostart=true
autorestart=true
user=www-data
numprocs=1
redirect_stderr=true
stdout_logfile=/home/forge/app.com/worker.log

Alter the paths and user settings according to your app.