php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65243 AMQPQueue->cancel not works w/o consumer tag, but you can't get consumer tag.
Submitted: 2013-07-11 10:40 UTC Modified: -
From: metamorfozis at metamorfozis dot hu Assigned:
Status: Open Package: amqp (PECL)
PHP Version: Irrelevant OS: ubuntu 12.10
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2013-07-11 10:40 UTC] metamorfozis at metamorfozis dot hu
Description:
------------
The problem is two fold:
 * AMQPQueue->cancel($consumer_tag) works, but normally with pecl AMQP you can't 
get the consumer tag
 * AMQPQueue->cancel() not works

The first problem is obvious. It would be great to have a getConsumerTag() method 
somewhere.

I have debugged the second problem, and the problem is that it sends an empty 
consumer tag, so because of that the cancel not happens. It also receives a 
Cancel-ok, as accordign to the reference the server should ignore nonexistent 
consumertags.



Test script:
---------------
<?php

[connection setup]


$channel=new AMQPChannel($conn);
$q=new AMQPQueue($channel);
$q->setName('cancel_test');
$q->setFlags(AMQP_DURABLE);
$q->declare();


$q->consume('processMessage');

function processMessage($envelope,$queue) {
    global $i,$argv;
    $i++;
    print "Something arrived... (".$i.")\n";
    $queue->ack($envelope->getDeliveryTag());
    if ($i == 2) {

        if ($argv[1] != '') {
            $queue->cancel($envelope->getBody());
            print "Cancelling myself with the received consumer tag...\n";
        } else {
            $queue->cancel($envelope->getBody());
            print "Cancelling myself...\n";
        }
    }
    if ($i == 10) {
        return false;
    }
    return true;
}
?>

Expected result:
----------------
No messages after cancelling. See actual results.



Actual result:
--------------
$ php -f amqpqueue_consume_cancel.php 
Something arrived... (1)
Something arrived... (2)
Cancelling myself...
Something arrived... (3)
^C


Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 11:01:21 2019 UTC