使用RabbitMQ进行异步队列处理

时间:2014-09-09 11:30:23

标签: php rabbitmq

我在RabbitMQ中找到异步队列处理的好例子时遇到了问题 我试图在服务器端开始实现类似的东西:

//here I declare the connection exchange and queue
$this->connection = new AMQPConnection('localhost', 5672, 'guest', 'guest');
$this->channel = $this->connection->channel();            
$this->channel->exchange_declare("exchange", 'direct', false, false, false);
list($this->queue_name, ,) = $this->channel->queue_declare("Queue", false, false, true, false);

while($envelope = $queue->get()) 
{
    // do work here...
}

问题是我返回的队列名称而不是队列引用,所以我可以在以下while循环中使用它。

我也尝试按照this link编写的方式创建和声明队列,但我的AMQPQueue已发送的包中没有RabbitMQ等类。

有人知道如何获得队列实例以便能够使用get方法吗?