PHP AMQP consumer probelm
===

I'm using the amqp extension in pecl 1.0.3, compiled with 2.7.1 rabbitmq. 

I'm trying to get a basic consumer/producer example working, but I keep getting errors. There's very little php documentation on this extension and a lot of it seemed to be outdated or wrong. 

I used the code a user posted, but can't seem to get the consumer part working


Connection:

    function amqp_connection() {
        $amqpConnection = new AMQPConnection();
        $amqpConnection->setLogin("guest");
        $amqpConnection->setPassword("guest");
        $amqpConnection->connect();

        if(!$amqpConnection->isConnected()) {
           die("Cannot connect to the broker, exiting !\n");
        }
        
        return $amqpConnection;
    }


Sender:
    
    function amqp_send($text, $routingKey, $exchangeName){
        $amqpConnection = amqp_connection();

        $channel = new AMQPChannel($amqpConnection);
        $exchange = new AMQPExchange($channel);
	
        $exchange->setName($exchangeName);
        $exchange->setType("fanout");
	
	
        if($message = $exchange->publish($text, $routingKey)){
           echo "sent";
        }
    
        if (!$amqpConnection->disconnect()) {
            throw new Exception("Could not disconnect !");
        }
    }

Receiver:
    
    function amqp_receive($exchangeName, $routingKey, $queueName) {
        $amqpConnection = amqp_connection();

        $channel = new AMQPChannel($amqpConnection);
        $queue = new AMQPQueue($channel);
        $queue->setName($queueName);
        $queue->bind($exchangeName, $routingKey);

        //Grab the info
        //...
    }


Then sending it:

    amqp_send("Abcdefg", "action", "amq.fanout");

And Receiving it:
    
    amqp_receive("amq.fanout","action","action");


I keep getting a problem running the script and points to the amqp receive:

    PHP Fatal error:  Uncaught exception 'AMQPQueueException' with message 'Server channel error: 404, message: NOT_FOUND - no queue 'action' in vhost '/'' in /home/jamescowhen/test.php:21

Can anyone point me to the right direction? The whole sample is from a user note here: 
[http://www.php.net/manual/en/amqp.examples.php#109024][1]

   


  [1]: http://www.php.net/manual/en/amqp.examples.php#109024