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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: metamorfozis at metamorfozis dot hu
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 12:01:33 2025 UTC