[rabbitmq-discuss] Blocking Queue - Close connection by client
mklishin at gopivotal.com
Mon Mar 3 09:04:10 GMT 2014
On 3 Mar 2014, at 12:18, Claire Fautsch <cfautsch at goodgamestudios.com> wrote:
> After some research we found out, that with a newer version of the official Java client, it is possible to use blocked connection notifications to react on this situation.
> Our prefered reaction would be to close the connection, and re-connect to another broker. Here however comes the problem: It is not possible to close the connection to the RabbitMQ, as the method to do so, involves a flush on the socket before the socket is closed and this is blocked as well.
> Is there any possibility for a force-closed on the client side? Or is the only possibility to open a new connection without closing the old one, and “let it die”?
Connection#abort is the same as Connection#close but ignores IOExceptions (EOFExceptions included).
This is just a workaround, though. Adding more consumer capacity to avoid frequently blocked connections
would be a better idea.
See also https://www.rabbitmq.com/blog/2014/01/23/preventing-unbounded-buffers-with-rabbitmq/
> Re-writing the SocketFrameHandler would of course also be a possibility, but one we would (if possible) like to avoid. (see also discussion here : https://github.com/rabbitmq/rabbitmq-java-client/issues/11)
So far the conclusion is that it will involve fairly significant changes because it’d be necessary to switch to NIO.
> Additionally, when we see blocking connections occurring, we frequently see following stack trace in our logs, where we are not absolutely sure where it comes from, or rather why it occurs
> com.rabbitmq.client.ShutdownSignalException: connection error; reason: java.io.EOFException
> at com.rabbitmq.utility.ValueOrException.getValue(ValueOrException.java:67)
> at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:37)
> at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:349)
> at com.rabbitmq.client.impl.ChannelN.close(ChannelN.java:569)
> at com.rabbitmq.client.impl.ChannelN.close(ChannelN.java:501)
You can inspect the cause exception’s trace (ShutdownSignalException#getCause).
Software Engineer, Pivotal/RabbitMQ
More information about the rabbitmq-discuss