[rabbitmq-discuss] python publish an unroutable message

Marek Majkowski majek04 at gmail.com
Wed Jul 21 13:41:16 BST 2010

On Tue, Jul 20, 2010 at 12:42, Ovidiu Deac <ovidiudeac at gmail.com> wrote:
>> Ovidiu Deac <ovidiudeac at gmail.com> writes:
>>> Does anyone have an example of using the mandatory flag to detect
>>> unroutable messages in python?

Pika: raises an exception on basic.return
look at pika/channel.py:
    def _async_basic_return(self, method_frame, header_frame, body):
        raise NotImplementedError("Basic.Return")

Pyamqplib: looks like it appends returned message to an internal queue:

That _basic_return code is executed only when you do ch.wait. This kind
of flow works for me:

ch.returned_messages.empty() -> True
ch.returned_messages.empty() -> False

On the other hand ch.returned_messages is a standard python Queue.Queue,
so it might be safe to just block on it in a separate thread.


More information about the rabbitmq-discuss mailing list