[rabbitmq-discuss] Confirmation listeners and closing a channel

Adam Rabung adamrabung at gmail.com
Mon Jan 23 20:39:52 GMT 2012


Hello,
I am trying to understand the effect ConfirmationListeners have on channel
closing.  It looks like if messages are published with "mandatory=true",
the corresponding Channel.close will block until all notifications have
been received (unsure of any timeout, I've seen it block for over a
minute).  I understand "mandatory" to mean "return the message to all
Return/Confirm listeners".  Is this blocking behavior also part of
mandatory behavior, or should close() happen immediately?

Something else interesting happens when you close a channel with pending
callbacks: listeners are immediately removed.  The consequence is you block
until all confirmations/returns have happened, but your listeners don't
receive them.

Here's some example code:
https://gist.github.com/1665378

If you call this with
RabbitTest.publish(0, exchange, routingKey, msg, brokerAddress);
prints "0 callbacks, waited 0ms before close, close took 5959"

RabbitTest.publish(5000, exchange, routingKey, msg, brokerAddress);
prints "427 callbacks, waited 5000ms before close, close took 833"

Note how both take roughly 5800ms.  On the first call, we don't pause
before calling close, and receive 0 callbacks. However, the second one,
which waits 5000ms before trying to call close, gets most of the callbacks.
 A longer pause before close results in all callbacks being handled.

To reproduce this, I use a roughly 200 character string as my message.
 It's also important that the message be published as "persistent" - I
think transient messages are too fast to reveal this :)

Should callbacks block close?  If so, should listeners continue to receive
callbacks as close happens?

Thank you,
Adam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20120123/b641b023/attachment.htm>


More information about the rabbitmq-discuss mailing list