ExceptionListeners
JMS Connection and JMSContext objects have an associated connection to a queue manager. Your application can register an ExceptionListener with a JMS Connection or JMSContext. If a problem occurs that makes the connection that is associated with the Connection or JMSContext unusable, the IBM MQ classes for JMS delivers an exception to the ExceptionListener by calling its onException() method. Your application then has the opportunity to reestablish the connection.
IBM MQ classes for JMS can also deliver an exception to the exception listener if a problem occurs while trying to deliver a message asynchronously.
Exception listeners
From IBM MQ Version 8.0.0, Fix Pack 2, to maintain behavior for current JMS applications that configure a JMS MessageListener and a JMS ExceptionListener, and to ensure that the IBM MQ classes for JMS are consistent with the JMS specification, the default value for the ConnectionFactory property ASYNCEXCEPTION is changed to ASYNC_EXCEPTIONS_CONNECTIONBROKEN. As a result, only exceptions that correspond to broken connection error codes are delivered to the ExceptionListener of an application.
APAR IT14820, included from IBM MQ Version 9.0.0, Fix Pack 1, updates IBM MQ classes for JMS so that:- An ExceptionListener that is registered by an application is invoked for any connection broken exceptions, regardless of whether the application is using synchronous or asynchronous message consumers.
- Non-connection broken exceptions (for example MQRC_GET_INHIBITED) that arise during message delivery are delivered to the ExceptionListener of an application when the application is using asynchronous message consumers and the JMS ConnectionFactory that is used by the application has the ASYNC_EXCEPTION property set to the value ASYNC_EXCEPTIONS_ALL.
Note: An ExceptionListener is invoked only once for a connection broken exception, even if two TCP/IP connections (one used by a JMS Connection and one used by a JMS Session) are broken. For any other type of problem, an exception is thrown by the current JMS API call. The type of exception that is thrown depends on the version of the JMS API that the application is using:
- If the application is using the interfaces that are provided by the JMS 1.1 specification, the exception is a JMSException. For more information on how to handle these exceptions, see Handling checked exceptions.
- If the application is using JMS 2.0 interfaces, the exception is a JMSRuntimeException. For more information on how to handle these exceptions, see Handling unchecked exceptions.
If an application does not register an exception listener with a Connection or JMSContext, any exceptions that would be delivered to the exception listener are written to the IBM MQ classes for JMS log.
Parent topic: Exceptions in IBM MQ classes for JMS