I have a Java rich client application that registers a durable subscription on a remote HornetQ JMS Topic on startup. However if the server restarts the connection is lost and can only be restored by restarting the client application. This leads to confusing situations where JMS messages are not received and after a client restart a lot of messages are received at once.
A simple solution to restore connection would be to run a timer to periodically check if the connection is still valid and try to reconnect otherwise. Alternatively the server could send a heartbeat to the client and try to reconnect if no heartbeat is received after a certain period (like mentioned in this answer).
But both seem like clumsy approaches to this problem and therefore I would like to know if there is a better solution to find out that the connection is not available anymore?