tnc/php-amqplib

Consuming old messages

Closed this issue · 1 comments

Hi

I have an issue regarding the consumption of "old" messages.

  1. I'm producing many messages in my test
  2. After stopping the producing script, I'm running 2 consumer scripts, with the same configuration using the basic_consume method.
  3. I'm just seeing one consumer consuming messages on the queue. The other consumer idles after the basic_consume() call.
  4. If I'm running the producer again, with 2 consumers, the first consumer works the old messages and the second consumer works the new messages.

I'm using one topic type Exchange ("testexchange") with one Queue bound ("testqueue") and routing ("routing.test").

What am I doing wrong?
I'd like to have all consumers work all messages in the queue.

Best
Daniel

$objAMQPChannel->exchange_declare('testexchange', 'topic', FALSE, TRUE, FALSE);
$objAMQPChannel->queue_declare('testqueue', false, true, false, false);
$objAMQPChannel->queue_bind('testqueue', 'testexchange', 'routing.test');

$objAMQPChannel->basic_consume('testqueue', posix_getpid(), FALSE, FALSE, FALSE, FALSE, $callbackFunctionName);
while(count($objAMQPChannel->callbacks)) {
$objAMQPChannel-->wait();
}

Found it.
You have to use basic_qos() to tell amqplib not to prefetch all messages by default.

Closing