How do I implement a listening queue in laravel? I'm using AMQP library
In RabbitMQ documentation this looks like that:
$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. Sorry for my English :|
I'd suggest installing AMQP Laravel driver. There are some:
It would do everything under the hood.