forked from php-amqp/php-amqp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
amqpexchange_declare_existent.phpt
46 lines (38 loc) · 1.24 KB
/
amqpexchange_declare_existent.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
--TEST--
AMQPExchange
--SKIPIF--
<?php if (!extension_loaded("amqp")) print "skip"; ?>
--FILE--
<?php
$cnn = new AMQPConnection();
$cnn->connect();
$ch = new AMQPChannel($cnn);
echo 'Channel id: ', $ch->getChannelId(), PHP_EOL;
$exchangge_name = "exchange-" . microtime(true);
$ex = new AMQPExchange($ch);
$ex->setName($exchangge_name);
$ex->setType(AMQP_EX_TYPE_FANOUT);
echo "Exchange declared: ", $ex->declareExchange() ? "true" : "false", PHP_EOL;
try {
$ex = new AMQPExchange($ch);
$ex->setName($exchangge_name);
$ex->setType(AMQP_EX_TYPE_TOPIC);
$ex->declareExchange();
} catch (AMQPExchangeException $e) {
echo $e->getMessage(), PHP_EOL;
}
echo "Channel connected: ", $ch->isConnected() ? "true" : "false", PHP_EOL;
echo "Connection connected: ", $cnn->isConnected() ? "true" : "false", PHP_EOL;
try {
$ex = new AMQPExchange($ch);
} catch (AMQPChannelException $e) {
echo $e->getMessage(), PHP_EOL;
}
?>
--EXPECTF--
Channel id: %d
Exchange declared: true
Server channel error: 406, message: PRECONDITION_FAILED - cannot redeclare exchange 'exchange-%d.%d' in vhost '/' with different type, durable, internal or autodelete value
Channel connected: false
Connection connected: true
Could not create exchange. No channel available.