Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Push to a different beanstalkd server

I have set my config to use my local beanstalkd server:

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

How do I push jobs to another beanstalkd server?

Queue::push(function($job)
{
  // This pushes to local beanstalkd
});

Queue::pushToRemoteBeanstalkdInstance(function($job)
{
  // ?
});
like image 990
Jürgen Paul Avatar asked Jul 04 '13 21:07

Jürgen Paul


1 Answers

You have to make an extra config in the queue config file, so it will look something like this:

'connections' => array(

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

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

If the default is set to "beanstalkd" you can keep calling it the normal way.

If you want to use the remote queue simply define the connection in the call like:

Queue::connection('beanstalkd_remote')->push(function($job)
{
    // This pushes to remote beanstalkd
});
like image 127
Nico Kaag Avatar answered Nov 01 '22 14:11

Nico Kaag