Exception Handling

It is important to consider implementing a JMS exception listener so that your client application is aware of errors that are reported asynchronously. If you do not implement an exception listener, some error conditions can cause the Eclipse Amlen JMS client to automatically close connections.

Client applications can detect errors that are reported asynchronously by using the ExceptionListener interface that is provided by JMS. Therefore, you might want to implement an exception listener if your application handles messages asynchronously. If your application implements a message listener, then you must implement an exception listener if you want problems that are reported asynchronously to be detected.

In Eclipse Amlen, there are cases where messages are sent asynchronously. For example, non-persistent messages are normally sent asynchronously. Messages that are sent on transacted sessions can be sent asynchronously by setting the AsyncTransactionSend connection factory property to true. Therefore, you might want to implement exception listeners for producer applications where these scenarios apply. There are two error conditions where theEclipse Amlen JMS client automatically closes connections to the Eclipse Amlen server for a message producer application that does not specify an exception listener:
  • When the server reports that it is out of memory CWLNC0231.
  • When the server reports that the capacity to store persistent messages is exceeded CWLNC0223.
If you want to handle the two error cases differently, then you must implement an exception listener and set the listener on the connection for your producer application. If you implement your own exception listener and you want to close the connection to the Eclipse Amlen server in these or other cases, then you must provide your own implementation to do this.