title: How can I recover unacknowledged AMQP messages from other channels than my connection's own?
body: <p>It seems the longer I keep my rabbitmq server running, the more trouble I have with unacknowledged messages. I would love to requeue them. In fact there seems to be an amqp command to do this, but it only applies to the channel that your connection is using. I built a little pika script to at least try it out, but I am either missing something or it cannot be done this way (how about with rabbitmqctl?)</p>
  
  <pre><code>import pika
  
  credentials = pika.PlainCredentials('***', '***')
  parameters = pika.ConnectionParameters(host='localhost',port=5672,\
      credentials=credentials, virtual_host='***')
  
  def handle_delivery(body):
      """Called when we receive a message from RabbitMQ"""
      print body
  
  def on_connected(connection):
      """Called when we are fully connected to RabbitMQ"""
      connection.channel(on_channel_open)    
  
  def on_channel_open(new_channel):
      """Called when our channel has opened"""
      global channel
      channel = new_channel
      channel.basic_recover(callback=handle_delivery,requeue=True)    
  
  try:
      connection = pika.SelectConnection(parameters=parameters,\
          on_open_callback=on_connected)    
  
      # Loop so we can communicate with RabbitMQ
      connection.ioloop.start()
  except KeyboardInterrupt:
      # Gracefully close the connection
      connection.close()
      # Loop until we're fully closed, will stop on its own
      connection.ioloop.start()
  </code></pre>