【发布时间】:2012-06-22 20:02:56
【问题描述】:
我有一个 python 应用程序,它使用 pika 库将消息推送到 rabbitMQ 队列。
message='hola'
credentials = pika.PlainCredentials('guest', 'guest')
connection = pika.BlockingConnection(pika.ConnectionParameters(credentials=credentials, host='localhost'))
channel = connection.channel()
channel.queue_declare(queue='myqueue')
channel.basic_publish(exchange='',routing_key='myqueue',body=message)
connection.close()
这行得通。
我需要在 php 应用程序中使用这些消息。我尝试了此页面的 AQMP 示例中提到的这个 - http://www.php.net/manual/en/class.amqpqueue.php(检查函数接收器)
$cnn = new AMQPConnection((array("host"=>"ec2-xxx-xx-xx-xxx.ap-southeast-1.compute.amazonaws.com","login"=>"guest", "password"=>"guest")));
if ($cnn->connect()) {
echo "Established a connection to the broker";
}
else {
echo "Cannot connect to the broker";
}
$queue = new AMQPQueue($cnn);
$queue->declare('myqueue');
$queue->bind('', 'myqueue');
$msg=$queue->get(AMQP_AUTOACK);
echo $msg->getBody();
抛出这个异常 -
Fatal error: Uncaught exception 'Exception' with message 'Error parsing parameters.' in /home/webroot/amqptest.php:12 Stack trace: #0 /home/webroot/amqptest.php(12): AMQPQueue->declare('myqueue') #1 {main} thrown in /home/webroot/amqptest.php on line 12
【问题讨论】:
-
错误是什么时候出现的?是连接的时候吗?还是在您正在消费的部分?