title: PHP AMQP consumer: Server channel error: 404, message: NOT_FOUND
body: <p>I'm using the amqp extension in pecl 1.0.3, compiled with 2.7.1 rabbitmq. </p>
  
  <p>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. </p>
  
  <p>I used the code a user posted, but can't seem to get the consumer part working</p>
  
  <p>Connection:</p>
  
  <pre><code>function amqp_connection() {
      $amqpConnection = new AMQPConnection();
      $amqpConnection-&gt;setLogin("guest");
      $amqpConnection-&gt;setPassword("guest");
      $amqpConnection-&gt;connect();
  
      if(!$amqpConnection-&gt;isConnected()) {
         die("Cannot connect to the broker, exiting !\n");
      }
  
      return $amqpConnection;
  }
  </code></pre>
  
  <p>Sender:</p>
  
  <pre><code>function amqp_send($text, $routingKey, $exchangeName){
      $amqpConnection = amqp_connection();
  
      $channel = new AMQPChannel($amqpConnection);
      $exchange = new AMQPExchange($channel);
  
      $exchange-&gt;setName($exchangeName);
      $exchange-&gt;setType("fanout");
  
  
      if($message = $exchange-&gt;publish($text, $routingKey)){
         echo "sent";
      }
  
      if (!$amqpConnection-&gt;disconnect()) {
          throw new Exception("Could not disconnect !");
      }
  }
  </code></pre>
  
  <p>Receiver:</p>
  
  <pre><code>function amqp_receive($exchangeName, $routingKey, $queueName) {
      $amqpConnection = amqp_connection();
  
      $channel = new AMQPChannel($amqpConnection);
      $queue = new AMQPQueue($channel);
      $queue-&gt;setName($queueName);
      $queue-&gt;bind($exchangeName, $routingKey);
  
      //Grab the info
      //...
  }
  </code></pre>
  
  <p>Then sending it:</p>
  
  <pre><code>amqp_send("Abcdefg", "action", "amq.fanout");
  </code></pre>
  
  <p>And Receiving it:</p>
  
  <pre><code>amqp_receive("amq.fanout","action","action");
  </code></pre>
  
  <p>I keep getting a problem running the script and points to the amqp receive:</p>
  
  <blockquote>
    <p>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</p>
  </blockquote>
  
  <p>Can anyone point me to the right direction? The whole sample is from a user note here: 
  <a href="http://www.php.net/manual/en/amqp.examples.php#109024" rel="nofollow noreferrer">http://www.php.net/manual/en/amqp.examples.php#109024</a></p>