Laravel:监听AMQP队列

时间:2017-03-22 00:53:46

标签: php laravel rabbitmq listener amqp

如何在laravel中实现侦听队列? 我正在使用AMQP library

在RabbitMQ文档中,它看起来像这样:

$connection = new AMQPStreamConnection('localhost', 5672, 'guest', 'guest');
$channel = $connection->channel();

$channel->queue_declare('hello', false, false, false, false);

$callback = function($msg) {
  echo " [x] Received ", $msg->body, "\n";
};

$channel->basic_consume('hello', '', false, true, false, false, $callback);

while(count($channel->callbacks)) {
    $channel->wait();
}

P.S。对不起我的英文:|

1 个答案:

答案 0 :(得分:0)

我建议安装AMQP Laravel驱动程序。有一些:

它将在后台进行所有操作。