$queue = 'AMQP_Test_Queue';
$exchange = 'AMQP_Test_Exchange';
$connectionO = new AMQPConnection(['host' => 'localhost', 'port' => '5672', 'vhost' => '/', 'login' => 'guest', 'password' => 'guest']);
$connectionO->connect();
$channelO = new AMQPChannel($connectionO);
$exchangeO = new AMQPExchange($channelO);
$exchangeO->setName($exchange);
$exchangeO->setType(AMQP_EX_TYPE_DIRECT);
$exchangeO->setFlags(AMQP_DURABLE); // 交换器进行持久化,即 RabbitMQ 重启后会自动重建。
$exchangeO->declareExchange(); // AMQP 1.2.0 由 declare() 改为 declareExchange();
$queueO = new AMQPQueue($channelO);
$queueO->setName($queue);
$queueO->setFlags(AMQP_DURABLE); // 队列进行持久化,即 RabbitMQ 重启后会自动重建。
$queueO->declareQueue(); // AMQP 1.2.0 由 declare() 改为 declareQueue();
$queueO->bind($exchange, 'key');
$result = $exchangeO->publish('Test', 'key', AMQP_NOPARAM, array('delivery_mode' => 2));
echo $result;
function test($a, $a2) {
print_r($a);
print_r($a2);
}
$queueO->consume('test');
$connectionO->disconnect();
?>
以上脚本中 publish() 死活写不进队列,但又返回 true,即 $result 值是 true。
CentOS 6.3 & PHP 5.5.1 & RabbitMQ 3.1.3 & PCEL AMQP 1.2.0
很诡异,大家有没有遇到过?
PHP
AMQP
RabbitMQ
一般会有错误日志吧...GFW 确实讨厌...
即使因为某些原因你不得不做这个GFW, 那么你也可以选择性的放一些“后门”在里面.至少让正常技术交流不成问题吧..一股脑全封了,是省事了,可是也留下了千古骂名.何苦来哉