title: How to know when connection to a JMS Topic is lost?
body: <p>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.</p>
  
  <p>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 <a href="https://stackoverflow.com/a/25143202/5337924">answer</a>).</p>
  
  <p>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?</p>