Can JMS utilities automatically re-establish a connection if one side of the communication link (i.e. an application that's sending/receiving messages) goes down and is restarted? Are there APIs to help detect that the other side broke a connection (went down)?

Showing Answers 1 - 4 of 4 Answers

Mani Solairaj

  • Jan 18th, 2006
 

Yes. You can write a snooper files to detect the service and restart the node upon node fail and a server instance fail.

  Was this answer useful?  Yes

Saurabh Saxena

  • Oct 2nd, 2011
 

When the network connection between the client and server is lost then JMS provider must try to re-establish the connection. If the JMS
provider cannot reconnect, the provider must notify the client.
JMS provides an ExceptionListener interface for this condition. The ExceptionListener is bound to the connection. The definition of the ExceptionListener
is:
public interface ExceptionListener{
void onException(JMSException exception);
}
javax.jms.Connection interface provides a way to register ExceptionListener.

Ref: http://java.sun.com/javaee/5/docs/api/
setExceptionListener
void setExceptionListener(ExceptionListener listener) throws JMSException

Sets an exception listener for this connection.

If a JMS provider detects a serious problem with a connection, it informs the connection's ExceptionListener, if one has been registered. It does this by calling the listener's onException method, passing it a JMSException object describing the problem.

An exception listener allows a client to be notified of a problem asynchronously. Some connections only consume messages, so they would have no other way to learn their connection has failed.

A connection serializes execution of its ExceptionListener.

A JMS provider should attempt to resolve connection problems itself before it notifies the client of them.

Parameters:
listener - the exception listener
Throws:
JMSException - if the JMS provider fails to set the exception listener for this connection.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions