views:

70

answers:

2

Is it possible to manage connection timeouts or errors in a MessageDrivenBean?

You can make the factory to retry connecting a certain number of times but... is it possible to make some actions each time that a reconnection retrial is neccesary? Is it possible to register an ExceptionListener into the MessageDrivenBean's connection somehow?

Thanks a lot.

A: 

You can always have some sort of error topic or queue that you can post the exception to from your MDB. Including the correlationID in the error message to synchronize with the original message if that is desired.

Robin
I'd like to, indeed :P. But the problem is that the MDB encapsulates all the connectivity exceptions and manages the exception by itself reconnecting if possible but leaving me with no possibility of handling it myself and doing any extra neccesary step apart from reconnecting.
Rafa de Castro
Any reason you aren't using a server defined pool to manage connections? Take it out of the applications hands altogether and let the server manage it.
Robin
The problem is that I need to explicitly know how many times connection got lost and recovered.
Rafa de Castro
If it is simply a matter of auditing/reporting, then you can simply post that information to another queue, or call an appropriate service. If you require some sort of action to be taken, why not simply call another service (synchronous) from within your MDB.
Robin
OK, maybe I am misunderstanding here. Are you having issues with connecting to the actual MDB, or making connections to something else from within the MDB?
Robin
The MDB gets its messages for a message topic that is in an openMQ that is on another machine. When I configure the factory that the application server uses to create the bean I can configure it to reconnect as many times as necessary but I need to know when it was necessary to reconnect and when it wasn't.
Rafa de Castro
A: 

Finally I wasn't able to do this but I changed jmsjra to JMSJCA that fits better my needings. JMSJCA is included in Glassfish ESB project.

Rafa de Castro