1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
|
--TEST--
AMQPEnvelope test get*() accessors
--SKIPIF--
<?php
if (!extension_loaded("amqp")) print "skip AMQP extension is not loaded";
elseif (!getenv("PHP_AMQP_HOST")) print "skip PHP_AMQP_HOST environment variable is not set";
?>
--FILE--
<?php
require '_test_helpers.php.inc';
$cnn = new AMQPConnection();
$cnn->setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
// Declare a new exchange
$ex = new AMQPExchange($ch);
$ex->setName('exchange-'. bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_FANOUT);
$ex->declareExchange();
// Create a new queue
$q = new AMQPQueue($ch);
$q->setName('queue1' . bin2hex(random_bytes(32)));
$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', null, array('headers' => array('foo' => 'bar')));
// Read from the queue
$msg = $q->get(null);
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) {
["contentType":"AMQPBasicProperties":private]=>
string(10) "text/plain"
["contentEncoding":"AMQPBasicProperties":private]=>
NULL
["headers":"AMQPBasicProperties":private]=>
array(1) {
["foo"]=>
string(3) "bar"
}
["deliveryMode":"AMQPBasicProperties":private]=>
int(1)
["priority":"AMQPBasicProperties":private]=>
int(0)
["correlationId":"AMQPBasicProperties":private]=>
NULL
["replyTo":"AMQPBasicProperties":private]=>
NULL
["expiration":"AMQPBasicProperties":private]=>
NULL
["messageId":"AMQPBasicProperties":private]=>
NULL
["timestamp":"AMQPBasicProperties":private]=>
int(0)
["type":"AMQPBasicProperties":private]=>
NULL
["userId":"AMQPBasicProperties":private]=>
NULL
["appId":"AMQPBasicProperties":private]=>
NULL
["clusterId":"AMQPBasicProperties":private]=>
NULL
["body":"AMQPEnvelope":private]=>
string(7) "message"
["consumerTag":"AMQPEnvelope":private]=>
string(0) ""
["deliveryTag":"AMQPEnvelope":private]=>
int(1)
["isRedelivery":"AMQPEnvelope":private]=>
bool(false)
["exchangeName":"AMQPEnvelope":private]=>
string(%d) "exchange-%s"
["routingKey":"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-%s"
isRedelivery:
bool(false)
getContentEncoding:
NULL
getType:
NULL
getTimeStamp:
int(0)
getPriority:
int(0)
getExpiration:
NULL
getUserId:
NULL
getAppId:
NULL
getMessageId:
NULL
getReplyTo:
NULL
getCorrelationId:
NULL
getHeaders:
array(1) {
["foo"]=>
string(3) "bar"
}
string(3) "bar"
string(3) "bar"
|