forked from php-amqp/php-amqp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
amqpqueue_get_headers.phpt
56 lines (46 loc) · 1.03 KB
/
amqpqueue_get_headers.phpt
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
--TEST--
AMQPQueue::get headers
--SKIPIF--
<?php if (!extension_loaded("amqp")) print "skip"; ?>
--FILE--
<?php
$cnn = new AMQPConnection();
$cnn->connect();
$ch = new AMQPChannel($cnn);
// Declare a new exchange
$ex = new AMQPExchange($ch);
$ex->setName('exchange' . time());
$ex->setType(AMQP_EX_TYPE_FANOUT);
$ex->declareExchange();
// Create a new queue
$q = new AMQPQueue($ch);
$q->setName('queue1' . time());
$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('body', 'routing.1', AMQP_NOPARAM, array("headers" => array(
"first" => "one",
"second" => 2
)));
// Read from the queue
$msg = $q->get(AMQP_AUTOACK);
echo $msg->getBody() . "\n";
var_dump($msg->getHeaders());
echo $msg->getContentType() . "\n";
echo $msg->getHeader("first") . "\n";
echo $msg->getHeader("second") . "\n";
$ex->delete();
$q->delete();
?>
--EXPECT--
body
array(2) {
["first"]=>
string(3) "one"
["second"]=>
int(2)
}
text/plain
one
2