How can I test if a JMS conneciton is alive?

Posted by nweddle on 26-Feb-2009 12:51

Consider the following scenario:

1. C#/Java client connects to Broker.

2. Broker restarts

3. At this point the Connection object is not null, but its usable. It will throw an exception is the client tried to publish a message.

How do I check if a connection is usable or not? I have not had any luck looking at the API docs.

All Replies

Posted by Bill Wood on 06-Feb-2010 11:00

Sending a message is really the only way to test an existing connection that does not have an exception listener.  What you want it to:

  • have an exception listener on the connection
  • make sure you set the ping interval on the connection

If a connection is only used for sending, then you need the ping or you won't know about the failure until the next message is sent.

This thread is closed