dusterio / laravel-plain-sqs

Custom SQS connector for Laravel (or Lumen) that supports third-party, plain JSON messages
MIT License
131 stars 92 forks source link

Can I using multiple connections for sending or listen queues? #42

Open gemaralali opened 4 years ago

gemaralali commented 4 years ago

I am using PHP >=5.6.4 & Lumen 5.5.* & laravel-plain-sqs ^0.1.16

in config/queue.php

'connections' => [ 'sqs-plain' => [ 'driver' => 'sqs-plain', 'key' => env('SQS_KEY', 'key'), 'secret' => env('SQS_SECRET', 'secret'), 'prefix' => env('SQS_PREFIX', 'prefix'), 'queue' => env('SQS_URL', 'queue'), 'region' => env('SQS_REGION', 'region'), ], 'sqs-plain-2' => [ 'driver' => 'sqs-plain-2', 'key' => env('SQS_KEY_2', 'key'), 'secret' => env('SQS_SECRET_2', 'secret'), 'prefix' => env('SQS_PREFIX_2', 'prefix'), 'queue' => env('SQS_URL_2', 'queue'), 'region' => env('SQS_REGION_2', 'region'), ] ]

what did I do to use multiple connections? whether I must do any configuration something for this?

Any suggestions would be helpful.

pmayet commented 4 years ago

Can you explain your use case ? Why different drivers ?

sshodges commented 4 years ago

I am using PHP >=5.6.4 & Lumen 5.5.* & laravel-plain-sqs ^0.1.16

in config/queue.php

'connections' => [ 'sqs-plain' => [ 'driver' => 'sqs-plain', 'key' => env('SQS_KEY', 'key'), 'secret' => env('SQS_SECRET', 'secret'), 'prefix' => env('SQS_PREFIX', 'prefix'), 'queue' => env('SQS_URL', 'queue'), 'region' => env('SQS_REGION', 'region'), ], 'sqs-plain-2' => [ 'driver' => 'sqs-plain-2', 'key' => env('SQS_KEY_2', 'key'), 'secret' => env('SQS_SECRET_2', 'secret'), 'prefix' => env('SQS_PREFIX_2', 'prefix'), 'queue' => env('SQS_URL_2', 'queue'), 'region' => env('SQS_REGION_2', 'region'), ] ]

what did I do to use multiple connections? whether I must do any configuration something for this?

Any suggestions would be helpful.

did you find an answer to this?

pixnbit commented 3 years ago

You could just use different queues with a same driver.

        $object = [
            'music' => 'M.I.A. - Bad girls',
            'time' => time()
        ];
        $job = new DispatcherJob($object);

        dispatch($job->setPlain())->onConnection('sqs-plain')->onQueue('LaravelTestQueue2');

The name of the queue matches the one you created on AWS. The name of the driver can also be specified other than the default one. But for your use case, you don't need a different driver.