1 Star 0 Fork 0

三仓库,镜像/php-amqp

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
amqpenvelope_get_accessors.phpt 3.03 KB
一键复制 编辑 原始数据 按行查看 历史
Bogdan Padalko 提交于 2017-06-09 07:04 +08:00 . Add consumer tag (#282)
--TEST--
AMQPEnvelope test get*() accessors
--SKIPIF--
<?php if (!extension_loaded("amqp")) print "skip"; ?>
--FILE--
<?php
require '_test_helpers.php.inc';
$cnn = new AMQPConnection();
$cnn->connect();
$ch = new AMQPChannel($cnn);
// Declare a new exchange
$ex = new AMQPExchange($ch);
$ex->setName('exchange-'.microtime(true));
$ex->setType(AMQP_EX_TYPE_FANOUT);
$ex->declareExchange();
// Create a new queue
$q = new AMQPQueue($ch);
$q->setName('queue1' . microtime(true));
$q->declareQueue();
// Bind it on the exchange to routing.key
$q->bind($ex->getName(), 'routing.*');
// Publish a message to the exchange with a routing key
$ex->publish('message', 'routing.1', AMQP_NOPARAM, array('headers' => array('foo' => 'bar')));
// Read from the queue
$msg = $q->get();
var_dump($msg);
dump_message($msg);
$header = $msg->getHeader('foo');
var_dump($header);
$header = 'changed';
$header = $msg->getHeader('foo');
var_dump($header);
?>
--EXPECTF--
object(AMQPEnvelope)#5 (20) {
["content_type":"AMQPBasicProperties":private]=>
string(10) "text/plain"
["content_encoding":"AMQPBasicProperties":private]=>
string(0) ""
["headers":"AMQPBasicProperties":private]=>
array(1) {
["foo"]=>
string(3) "bar"
}
["delivery_mode":"AMQPBasicProperties":private]=>
int(1)
["priority":"AMQPBasicProperties":private]=>
int(0)
["correlation_id":"AMQPBasicProperties":private]=>
string(0) ""
["reply_to":"AMQPBasicProperties":private]=>
string(0) ""
["expiration":"AMQPBasicProperties":private]=>
string(0) ""
["message_id":"AMQPBasicProperties":private]=>
string(0) ""
["timestamp":"AMQPBasicProperties":private]=>
int(0)
["type":"AMQPBasicProperties":private]=>
string(0) ""
["user_id":"AMQPBasicProperties":private]=>
string(0) ""
["app_id":"AMQPBasicProperties":private]=>
string(0) ""
["cluster_id":"AMQPBasicProperties":private]=>
string(0) ""
["body":"AMQPEnvelope":private]=>
string(7) "message"
["consumer_tag":"AMQPEnvelope":private]=>
string(0) ""
["delivery_tag":"AMQPEnvelope":private]=>
int(1)
["is_redelivery":"AMQPEnvelope":private]=>
bool(false)
["exchange_name":"AMQPEnvelope":private]=>
string(%d) "exchange-%f"
["routing_key":"AMQPEnvelope":private]=>
string(9) "routing.1"
}
AMQPEnvelope
getBody:
string(7) "message"
getContentType:
string(10) "text/plain"
getRoutingKey:
string(9) "routing.1"
getConsumerTag:
string(0) ""
getDeliveryTag:
int(1)
getDeliveryMode:
int(1)
getExchangeName:
string(%d) "exchange-%f"
isRedelivery:
bool(false)
getContentEncoding:
string(0) ""
getType:
string(0) ""
getTimeStamp:
int(0)
getPriority:
int(0)
getExpiration:
string(0) ""
getUserId:
string(0) ""
getAppId:
string(0) ""
getMessageId:
string(0) ""
getReplyTo:
string(0) ""
getCorrelationId:
string(0) ""
getHeaders:
array(1) {
["foo"]=>
string(3) "bar"
}
string(3) "bar"
string(3) "bar"
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/third-repo/php-amqp.git
git@gitee.com:third-repo/php-amqp.git
third-repo
php-amqp
php-amqp
master

搜索帮助