[rabbitmq-discuss] Java waitForConfirmsOrDie(timeout) can block indefinitely
stuart.sierra at cognitect.com
Thu Oct 24 15:40:22 BST 2013
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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the rabbitmq-discuss