tags:

views:

108

answers:

3

When there is a network problem which results in the client being disconnected from the JMS server, is there some other way to detect the problem other than waiting until the next JMS message being sent fails?

+1  A: 

You can register an ExceptionListner with the JMS Connection using Connection.setExceptionListener(ExceptionListener)

The ExceptionListener will get notified of more problems than an actual disconnection, so you may have to filter the JMSException that gets passed to the listener.

skaffman
+2  A: 

ExceptionListener isn't necessarily enough. You need to catch exceptions on any JMS calls you make (sending messages, for example). See http://stackoverflow.com/questions/47683/reconnecting-jms-listener-to-jbossmq/117503#117503

John M
A: 

if your are running on MQ and looking to solve this problem, install a local MQ instance. More license but you will get guaranty delivery if your main corporate MQ goes down.

Other Option, use Spring and let the framework do the recovery of the connection.

Aerosteak
I am not sure adding a massive spring library is the best solution to handling reconnecting to a JMS queue. (:
corydoras