I see how much RabbitMQ fits my task.

Code from the example

$consumerTag = gethostname() . '_' . getmypid(); $connection = $this->getConnection(); $channel = $this->getChannel(); $channel->basic_qos(null, 1, null); $channel->queue_bind(self::QUEUE_NAME, 'exchange'); $channel->basic_consume(self::QUEUE_NAME, $consumerTag, false, true, false, false, function($msg) { echo $msg->body, "\n"; sleep(2); }); while(count($channel->callbacks)) { echo time()."\r\n"; $channel->wait(); } 

Is it possible to get several messages from the queue in a callback? Perhaps it is generally contrary to the ideology of RabbitMQ?

  • A callback is probably called for each message separately. but this cannot be a barrier for a hero - Sergey
  • @Sergey, that's it =) - flax

1 answer 1

Understood, to receive the next message without waiting, you can use

 $channel->basic_get(self::QUEUE_NAME)