I'm using JMS (Apache Qpid) to create connections to a message broker. I do create some connections and cache those in a Map (Map<String, Connection>
). However, the message broker has its natural limits (in terms of resources like connections per user) which gets hit a some time. If I configure a connection via Qpid to use an idle timeout the connections in my map will constantly disconnect and connect again. Let's say the limit of connection is set to 3 and I create a 4th connection right in the moment when an idle timeout kicks in the 4th connection might connect and "steal" the connection. So the 4 connections will fight for the limit the message broker has. I've registered an exception listener and I do see the error occuring. I would like to close an connection on a specific error but it seems like I've no controll about that.
So how do I manage the lifecycle of a connection? Is there a way to get information about if a connection is connected or not?