php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59877 AMQP_NOACK on AMQPQueue::get not respected
Submitted: 2011-08-01 07:33 UTC Modified: 2011-10-17 04:04 UTC
From: luke at lukelanchester dot com Assigned: pdezwart (profile)
Status: Closed Package: amqp (PECL)
PHP Version: 5.3.2 OS: OS X 10.6.2
Private report: No CVE-ID: None
 [2011-08-01 07:33 UTC] luke at lukelanchester dot com
Description:
------------
When using AMQPQueue to read messages, it reads messages 
correctly. However, using the AMQP_NOACK flag seems to have no 
effect as messages are still being acknowledged. It appears 
others have experienced this as well (search StackOverflow).

Reproduce code:
---------------
<?php

// Example borrowed from http://www.php.net/manual/en/amqp.examples.php#104117

$exchangeName = 'myexchange';
$routingKey = 'routing.key';
$queueName = 'myqueue';

// connect
$connection = new AMQPConnection();
$connection->connect();

// setup our queue
$q = new AMQPQueue($connection);
$q->declare($queueName);

// Bind it on the exchange to routing.key
$q->bind($exchangeName, $routingKey);

// show the message
print_r($q->get(AMQP_NOACK));

// Should return same message in theory
print_r($q->get(AMQP_NOACK));

$connection->disconnect();

Expected result:
----------------
Same message returned as previous get() not acknowledged

Actual result:
--------------
The next message in the queue and queue count decremented by 
1.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-09-28 04:43 UTC] qwaser at gmail dot com
Confirmed on PHP 5.3.5 and amqp 0.3.1
 [2011-10-11 06:13 UTC] php at aotd dot ru
It's not a bug, but normal situation.
$q->get(AMQP_NOACK) set NOACK flag for message and it _skipped_ by next get() 
commands.
When you disconnect all unacknowledged messages drop this flag and can be fetched 
by get() again.
 [2011-10-17 04:04 UTC] pdezwart@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: pdezwart
 [2011-10-17 04:04 UTC] pdezwart@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

This is actually the expected behavior. Providing the AMQP_NOACK flag indicates that you will not be ack'ing the message, and that the server should instead ack it as soon as it sends it off to the client. Unfortunately, there is a bug in that you cannot get/consume without acking. This will be fixed in trunk shortly and be part of the 0.4.* release.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Apr 15 11:01:24 2021 UTC