I create RabbitMQ listener:
$connection = new AMQPConnection(
$AMQP_config['server'],
$AMQP_config['port'],
$AMQP_config['user'],
$AMQP_config['password'],
$AMQP_config['virtual_host']
);
$channel = $connection->channel();
$channel->basic_qos(
null,
1,
null
);
$channel->basic_consume(
$AMQP_config['queue'],
'',
false,
false,
false,
false,
array($this, 'CallbackResponse')
);
while(count($channel->callbacks)) {
$channel->wait();
}
$channel->close();
$connection->close();
public function CallbackResponse(AMQPMessage $msg)
{
$response = json_decode($msg->body)->acopMessage;
if ($response->reqMRef == $this->_request_reference) {
$msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']);
}
}
I have 5 messages on my RabbitMQ server. But I receive only one callback, only one entering into CallbackResponse().
I want to check all messages from the queue, find the one I've sent, read it, so there will be 4 messages left.
What I doing wrong, why I receive only first message?
Using this: https://github.com/videlalvaro/php-amqplib