'BlockingChannel.basic_recover with requeue=True.
NOTE: the requeue=False option is not supported by RabbitMQ broker as
of this writing (using RabbitMQ 3.5.1)'

def test(self):

    connection = self._connect()
    ch = connection.channel()
    q_name = ('TestBasicRecoverWithRequeue_q' + uuid.uuid1().hex)
    ch.confirm_delivery()
    ch.queue_declare(q_name, auto_delete=True)
    self.addCleanup(self._connect().channel().queue_delete, q_name)
    ch.publish(exchange='', routing_key=q_name, body='TestBasicRecoverWithRequeue1', mandatory=True)
    ch.publish(exchange='', routing_key=q_name, body='TestBasicRecoverWithRequeue2', mandatory=True)
    rx_messages = []
    num_messages = 0
    for msg in ch.consume(q_name, no_ack=False):
        num_messages += 1
        if (num_messages == 2):
            ch.basic_recover(requeue=True)
        if (num_messages > 2):
            rx_messages.append(msg)
        if (num_messages == 4):
            break
    else:
        self.fail('consumer    aborted    prematurely')
    (_, _, rx_body) = rx_messages[0]
    self.assertEqual(rx_body, as_bytes('TestBasicRecoverWithRequeue1'))
    (_, _, rx_body) = rx_messages[1]
    self.assertEqual(rx_body, as_bytes('TestBasicRecoverWithRequeue2'))
