def on_return(self, channel, method, properties, body):
        """Invoked by RabbitMQ when it returns a message that was published.

        :param channel: The channel the message was delivered on
        :type channel: pika.channel.Channel
        :param method: The AMQP method frame
        :type method: pika.frame.Frame
        :param properties: The AMQP message properties
        :type properties: pika.spec.Basic.Properties
        :param bytes body: The message body

        """
        pending = self.pending_confirmations()
        if not pending:  # Exit early if there are no pending messages
            self.logger.warning('RabbitMQ returned message %s and no pending '
                                'messages are unconfirmed',
                                utils.message_info(method.exchange,
                                                   method.routing_key,
                                                   properties))
            return

        self.logger.warning('RabbitMQ returned message %s: (%s) %s',
                            utils.message_info(method.exchange,
                                               method.routing_key, properties),
                            method.reply_code, method.reply_text)

        # Try and match the exact message or first message published that
        # matches the exchange and routing key
        for offset, msg in pending:
            if (msg.message_id == properties.message_id or
                    (msg.exchange == method.exchange and
                     msg.routing_key == method.routing_key)):
                self.published_messages[offset].future.set_result(False)
                return

        # Handle the case where we only can go on message ordering
        self.published_messages[0].future.set_result(False)
Invoked by RabbitMQ when it returns a message that was published.

        :param channel: The channel the message was delivered on
        :type channel: pika.channel.Channel
        :param method: The AMQP method frame
        :type method: pika.frame.Frame
        :param properties: The AMQP message properties
        :type properties: pika.spec.Basic.Properties
        :param bytes body: The message body