dlarchikov / php-amqplib

Automatically exported from code.google.com/p/php-amqplib
GNU Lesser General Public License v2.1
0 stars 0 forks source link

Messages are not being ACKed correctly (in demo script) #5

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Send a durable message using amqp_publisher.php script
2. Receive message using  amqp_consumer.php script
3. list queues i operating exchange: 
   rabbitmqctl list_queues -p /test
(or restart the consumer - the same message will be received again)

What is the expected output? What do you see instead?
Listing queues ...
test_queue        1
done.

instead of:
Listing queues ...
test_queue        0
done.

What version of the product are you using? On what operating system?
latest / linux

Please provide any additional information below.

I'm not sure where it should be fixed. 
Messages are not being ACKed correctly because $msg->delivery_tag does not
return a delivery_tag. 
The delivery_tag can be fetched from $msg->delivery_info['delivery_tag']
or $msg->delivery_tag should also return a proper delivery_tag
A quick fix solution will be: 
--- amqp_consumer.php.orig      2009-08-20 11:08:43.000000000 +0100
+++ amqp_consumer.php   2009-08-20 10:40:38.000000000 +0100

@@ -38,7 +38,7 @@
     echo $msg->delivery_info['delivery_tag'];
     echo "\n--------\n";

-    $ch->basic_ack($msg->delivery_tag);
+    $ch->basic_ack($msg->delivery_info['delivery_tag']);

     // Cancel callback
     if ($msg->body === 'quit') {

Original issue reported on code.google.com by cezary.s...@gmail.com on 20 Aug 2009 at 10:15

GoogleCodeExporter commented 8 years ago
sorry, previous diff was incorrect 

--- amqp_consumer.php.orig      2009-08-20 12:52:39.000000000 +0100
+++ amqp_consumer.php   2009-08-20 12:53:48.000000000 +0100
@@ -33,7 +33,7 @@
     echo $msg->body;
     echo "\n--------\n";

-    $ch->basic_ack($msg->delivery_tag);
+    $ch->basic_ack($msg->delivery_info['delivery_tag']);

     // Cancel callback
     if ($msg->body === 'quit') {

Original comment by cezary.s...@gmail.com on 20 Aug 2009 at 11:54

GoogleCodeExporter commented 8 years ago
patch commited. thanks

Original comment by kroko...@gmail.com on 21 Aug 2009 at 12:35