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: 2021-06-10 15:36 UTC
From: metamorfozis at metamorfozis dot hu Assigned: cmb (profile)
Status: Closed Package: amqp (PECL)
PHP Version: Irrelevant OS: ubuntu 12.10
Private report: No CVE-ID: None
 [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

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-06-10 15:36 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2021-06-10 15:36 UTC] cmb@php.net
The amqp bug tracker is now on Github[1].  If this is still an
issue, please report there.

[1] <https://github.com/php-amqp/php-amqp/issues>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 05:01:28 2024 UTC