【问题标题】:Push to a different beanstalkd server推送到不同的 beanstalkd 服务器
【发布时间】:2013-07-04 21:22:26
【问题描述】:

我已将配置设置为使用本地 beanstalkd 服务器:

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

如何将作业推送到另一个 beanstalkd 服务器?

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

Queue::pushToRemoteBeanstalkdInstance(function($job)
{
  // ?
});

【问题讨论】:

    标签: laravel laravel-4 beanstalkd


    【解决方案1】:

    你必须在队列配置文件中做一个额外的配置,所以它看起来像这样:

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

    如果默认设置为“beanstalkd”,您可以继续以正常方式调用它。

    如果您想使用远程队列,只需在调用中定义连接,如下所示:

    Queue::connection('beanstalkd_remote')->push(function($job)
    {
        // This pushes to remote beanstalkd
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-26
      • 2014-03-24
      • 1970-01-01
      相关资源
      最近更新 更多