[rabbitmq-discuss] Java waitForConfirmsOrDie(timeout) can block indefinitely

Stuart Sierra stuart.sierra at cognitect.com
Thu Oct 24 15:40:22 BST 2013


Hello list,

It appears that flow control can cause the Java API to block indefinitely
on the call to Channel.waitForConfirmsOrDie(long timeout), regardless of
the timeout value.

Is this intentional?

I tested this with RabbitMQ 3.2.0 and the official Java client 3.2.0.

Steps to reproduce:

   1. Start a RabbitMQ broker
   2. Connect with the Java client
   3. Create a Channel and call `confirmSelect`
   4. Run `rabbitmqctl set_vm_memory_high_watermark 0.0`
   5. Call `basicPublish` to publish a message
   6. Call `Channel.waitForConfirmsOrDie(1000L)`
   7. Wait for more than 1 second: no exception
   8. Run `rabbitmqctl set_vm_memory_high_watermark 0.4`
   9. TimeoutException is thrown

I think this is because ChannelN.waitForConfirmsOrDie(long timeout) catches
TimeoutException and calls:

close(AMQP.PRECONDITION_FAILED, "TIMEOUT WAITING FOR ACK");


The call to `close` blocks indefinitely because the RabbitMQ connection is
blocked. The TimeoutException does not get thrown until after the
connection is unblocked.

As a workaround, I am calling `Channel.waitForConfirms(long timeout)` and
throwing an exception if returns false.

Regards,
Stuart Sierra
Cognitect, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20131024/fdb1b469/attachment.htm>


More information about the rabbitmq-discuss mailing list