title: pika rabbitmq topic producer. do I have to bind a routing key(s) to the queue?
body: <p>I understand the need for a topic <em>consumer</em> to bind all of the routing keys it's interest in receiving, but I'm a bit confused as to why the topic <em>producer</em> in the following example </p>
  
  <p><a href="https://github.com/pika/pika/blob/master/docs/examples/asynchronous_publisher_example.rst" rel="nofollow">https://github.com/pika/pika/blob/master/docs/examples/asynchronous_publisher_example.rst</a></p>
  
  <pre><code>def on_queue_declareok(self, method_frame):
          """Method invoked by pika when the Queue.Declare RPC call made in
          setup_queue has completed. In this method we will bind the queue
          and exchange together with the routing key by issuing the Queue.Bind
          RPC command. When this command is complete, the on_bindok method will
          be invoked by pika.
  
          :param pika.frame.Method method_frame: The Queue.DeclareOk frame
  
          """
          LOGGER.info('Binding %s to %s with %s',
                      self.EXCHANGE, self.QUEUE, self.ROUTING_KEY)
          self._channel.queue_bind(self.on_bindok, self.QUEUE,
                                   self.EXCHANGE, self.ROUTING_KEY)
  </code></pre>
  
  <p>in <code>on_queue_declareok()</code> binds the queue to a routing key since the producer isn't listening for any topics.  Am I supposed to bind all of the routing keys which the producer will send out?</p>
  
  <p>I know that the following example </p>
  
  <p><a href="http://www.rabbitmq.com/tutorials/tutorial-five-python.html" rel="nofollow">http://www.rabbitmq.com/tutorials/tutorial-five-python.html</a></p>
  
  <p>is using a blocking connection as compared to the SelectConnection which I'm using, but it's producer doesn't bind any routing keys to the queue - it simply does basic_publish() for an arbitrary routing key.</p>
  
  <pre><code>#!/usr/bin/env python
  import pika
  import sys
  
  connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
  channel = connection.channel()
  
  channel.exchange_declare(exchange='topic_logs', type='topic')
  
  routing_key = sys.argv[1] if len(sys.argv) &gt; 1 else 'anonymous.info'
  message = ' '.join(sys.argv[2:]) or 'Hello World!'
  channel.basic_publish(exchange='topic_logs', routing_key=routing_key, body=message)
  print " [x] Sent %r:%r" % (routing_key, message)
  connection.close()
  </code></pre>
  
  <p>Any clarification would be appreciated.</p>
  
  <p>-Scott</p>