Question

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)
{
  // ?
});
Was it helpful?

Solution

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
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top