|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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"
}
}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 10:00:01 2025 UTC |
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) } }