Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel and Multiple SQS (queue) configs

Is there a method on the Queue class that can specify a specific connection as defined in the queue config? There's a similar option for MySql, where you can define 'mysql2', and then call:

DB::connection('mysql2')->table('etc')->get();

Is there a similar option for queues?

Something like:

Queue::connection('sqs2')->push('MyQueue', array('message' => $message));
like image 622
egekhter Avatar asked Jun 29 '14 10:06

egekhter


1 Answers

Apparently I answered my own question above without even realizing it. You can have multiple queues and specify which one you want to push the message to by using a connection method.

Here's what my partial config looks like for anybody that's interested:

    'default' => 'sqs',

   'connections' => array(

    'sync' => array(
        'driver' => 'sync',
    ),

    'beanstalkd' => array(
        'driver' => 'beanstalkd',
        'host'   => 'localhost',
        'queue'  => 'default',
    ),

    'sqs' => array(
        'driver' => 'sqs',
        'key'    => 'xxxxxxxxxxxx',
        'secret' => 'yyyyyyyyyyyyyy',
        'queue'  => 'https://sqs.us-west-2.amazonaws.com/zzzzzzzzz',
        'region' => 'us-west-2',
    ),

    'sqs2' => array(
        'driver' => 'sqs',
        'key'    => 'uuuuuuuuuuuuu',
        'secret' => 'vvvvvvvvvvvvvvvv',
        'queue'  => 'https://sqs.us-west-2.amazonaws.com/wwwwwwwwwww',
        'region' => 'us-west-2',
    ),
like image 56
egekhter Avatar answered Dec 12 '22 10:12

egekhter