php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59760 AMQPQueue::consume
Submitted: 2011-05-10 04:41 UTC Modified: 2011-05-31 15:47 UTC
From: maohangjun at gmail dot com Assigned:
Status: Closed Package: amqp (PECL)
PHP Version: 5.3.5 OS: CentOS release 5.6 x86_64
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: maohangjun at gmail dot com
New email:
PHP Version: OS:

 

 [2011-05-10 04:41 UTC] maohangjun at gmail dot com
Description:
------------
when use AMQPQueue::consume the message_body is the same,why?


amqp-0.2.2.tgz 
rabbitmq-server-2.2.0-1.el5

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

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

// Declare a new exchange
$ex = new AMQPExchange($cnn);
$ex->declare('exchange1', AMQP_EX_TYPE_FANOUT);

// Create a new queue
$q = new AMQPQueue($cnn);
$q->declare('queue1');

// Bind it on the exchange to routing.key
$ex->bind('queue1', 'routing.*');

// Publish a message to the exchange with a routing key
$ex->publish('message', 'routing.1');
$ex->publish('message2', 'routing.2');
$ex->publish('message3', 'routing.3');

// Read from the queue
$options = array(
 'min' => 1,
 'max' => 10,
 'ack' => false
);
$msg = $q->consume($options);
var_dump($msg);
?>

Expected result:
----------------
array(3) {
  [0]=>
  array(7) {
    ["consumer_tag"]=>
    string(33) "amq.ctag-BmQ5r8r6hiAw8vfDoJZQTg=="
    ["delivery_tag"]=>
    int(3)
    ["redelivered"]=>
    bool(false)
    ["routing_key"]=>
    string(9) "routing.3"
    ["exchange"]=>
    string(9) "exchange1"
    ["Content-type"]=>
    string(10) "text/plain"
    ["message_body"]=>
    string(8) "message3"
  }
  [1]=>
  array(7) {
    ["consumer_tag"]=>
    string(33) "amq.ctag-BmQ5r8r6hiAw8vfDoJZQTg=="
    ["delivery_tag"]=>
    int(3)
    ["redelivered"]=>
    bool(false)
    ["routing_key"]=>
    string(9) "routing.3"
    ["exchange"]=>
    string(9) "exchange1"
    ["Content-type"]=>
    string(10) "text/plain"
    ["message_body"]=>
    string(8) "message3"
  }
  [2]=>
  array(7) {
    ["consumer_tag"]=>
    string(33) "amq.ctag-BmQ5r8r6hiAw8vfDoJZQTg=="
    ["delivery_tag"]=>
    int(3)
    ["redelivered"]=>
    bool(false)
    ["routing_key"]=>
    string(9) "routing.3"
    ["exchange"]=>
    string(9) "exchange1"
    ["Content-type"]=>
    string(10) "text/plain"
    ["message_body"]=>
    string(8) "message3"
  }
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-05-24 09:17 UTC] hlopetz at gmail dot com
the same with PHP 5.2.17:

array(3) {
  [0]=>
  array(8) {
    ["consumer_tag"]=>
    string(33) "amq.ctag-CwkwldNku5e7uTrLDSjGgQ=="
    ["delivery_tag"]=>
    int(3)
    ["redelivered"]=>
    bool(false)
    ["routing_key"]=>
    string(25) "com.percona.billing.times"
    ["exchange"]=>
    string(13) "billing_times"
    ["Content-type"]=>
    string(10) "text/plain"
    ["message_body"]=>
    string(44) "
{"issue_id":"1111","timestamp":"1306195200"}"
    ["acked"]=>
    bool(true)
  }
  [1]=>
  array(8) {
    ["consumer_tag"]=>
    string(33) "amq.ctag-CwkwldNku5e7uTrLDSjGgQ=="
    ["delivery_tag"]=>
    int(3)
    ["redelivered"]=>
    bool(false)
    ["routing_key"]=>
    string(25) "com.percona.billing.times"
    ["exchange"]=>
    string(13) "billing_times"
    ["Content-type"]=>
    string(10) "text/plain"
    ["message_body"]=>
    string(44) "
{"issue_id":"1111","timestamp":"1306195200"}"
    ["acked"]=>
    bool(true)
  }
  [2]=>
  array(8) {
    ["consumer_tag"]=>
    string(33) "amq.ctag-CwkwldNku5e7uTrLDSjGgQ=="
    ["delivery_tag"]=>
    int(3)
    ["redelivered"]=>
    bool(false)
    ["routing_key"]=>
    string(25) "com.percona.billing.times"
    ["exchange"]=>
    string(13) "billing_times"
    ["Content-type"]=>
    string(10) "text/plain"
    ["message_body"]=>
    string(44) "
{"issue_id":"1111","timestamp":"1306195200"}"
    ["acked"]=>
    bool(true)
  }
}
 [2011-05-24 16:03 UTC] dsmflyer at gmail dot cpm
Fixed:

- Removed unused variables from consume function
- Fixed writing to unallocated memory space causing segmentation fault
- Fixed the overwriting of same memory space so messages are preserved.
 [2011-05-31 15:47 UTC] dsmflyer at gmail dot com
This bug has been fixed in SVN.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on pecl.php.net.

In case this was a pecl.php.net website problem, the change will show
up on the website in short time.
 
Thank you for the report, and for helping us make PECL better.

Fixed so that messages are now consume correctly, and not lost in memory.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 09:01:28 2024 UTC