We use the ConnectionListener interface provided by Spring-AMQP to keep a tab on the underlying connection. The channel is created with autorecovery with a heartbeat set to 10 mins (for some product needs). My observation is the connectionListener.onClose() method does not get called for almost 10 mins even after the underlying rabbitMQ has died.
We also do a health status check on the API and use the connectionListener.isOpen() method to determine the state of the connection.
And because of this code block in the SimpleConnection class
@Override public boolean isOpen() { return delegate != null && (delegate.isOpen() || this.delegate.getClass().getSimpleName().contains("AutorecoveringConnection")); }
always returns true as the connection is auto recovering. Because of which the Health API does not learn of the connection failure for 10 mins after the connection has died.
Is there any recommended way to notify the ConnectionListener of the channel closures as the isOpen method is clearly not serving the need?
Is implementing the ShutDownlistener the way to go? Since we do not have access to the channel in the connectionListerner and cannot directly do connection.addConnectionListerner (this). From the connectionFactory shutdownCompleted method is it possible to invoke the onClose or any other method on the connectionListener to notify it of closure?
Any other thoughts?