Sunday, 9 January 2011

How to do MDB error handling

If an MDB is consuming a message when an unexpected error occurs most programmers think that the obvious thing to do is to throw an exception back to the MDB's container. The container can then decide how to handle the error: drop the message, delay for a while and then resend depending on how JMS queue or topic is configured.

If your MDB is transactional, then to inform the container of your error all you need to do is to use the bean context to call setRollbackOnly().

To inform the container of a problem for any MDB—transactional or non-transactional—you can throw an exception derived from the RuntimeException or Error thrown by the MDB. This causes the MDB instance to be destroyed and re-created, which incurs a performance penalty.

For more information, take a look at the Weblogic / Oracle website

Applies to Weblogic webserver.

No comments: