Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php get message from rabbitmq error

Tags:

php

rabbitmq

My amqp extension version is 1.0.1 & AMQP protocol version is 0-9-1

get messages from queue :

<?php
try {
$conn = new AMQPConnection() ;
$conn->setLogin('guest') ;
$conn->setPassword('guest') ;
$conn->connect() ;
if ($conn->isConnected()) {
    $channel = new AMQPChannel($conn) ;
    if ($channel->isConnected())
    {
        $queue = new AMQPQueue($channel) ;
        $queue->setName('test_queue') ;
        $queue->setFlags(AMQP_DURABLE | AMQP_AUTODELETE) ;
        $queue->declare() ;
        $messages = $queue->get(AMQP_AUTOACK) ;
        print_r($messages->getBody()) ;
    }
} else {
    echo "connect failure ... " ;
}
$conn->disconnect() ;} catch (Exception $e) {
echo $e->getMessage() ;}?>

and it doesn't work ..

Server channel error: 406, message: PRECONDITION_FAILED - parameters for queue 'test_queue' in vhost '/' not equivalent
like image 346
nate Avatar asked Mar 15 '12 07:03

nate


People also ask

What happens when RabbitMQ is down?

If your consumer is down, RabbitMQ stores the messages and forwards them when the consumer comes back up. Of course RabbitMQ itself could be unavailable, but then your producer (publisher) wouldn't be able to enqueue its messages and would have to stop working until the RabbitMQ broker came back online.

Is RabbitMQ push or pull?

RabbitMQ: Push-based approachRabbitMQ uses a push model and stops overwhelming consumers through a prefetch limit defined on the consumer. This can be used for low latency messaging..

What is RabbitMQ PHP?

Essentially, one of the application endpoints sends a message, thus being a Producer, through an AMQP broker. In turn the broker will deliver the message to another application endpoint, called the Consumer. RabbitMQ is an AMQP broker that has support for several programming languages, such as PHP.


1 Answers

It seems to me that the queue already exists and it was declared (created) previously with different parameters in the vhost. Queues need to be declared exactly with the same parameters every time (or deleted and recreated with the desired parameters). Try deleting the queue via the management plugin (http://www.rabbitmq.com/management.html) and then running your script again

like image 54
marcelog Avatar answered Oct 15 '22 11:10

marcelog