Your bean should only be handling the exceptions relevent to the bean's purpose. Other exceptions (Errors, RuntimeExceptions etc) will be caught by the container and then handled according to how you have configured you system.
The approach I prefer is to have the container retry the message a few times with a reasonable delay between them and then, as a last resort, send the message to a different queue specifically designed to handled failed messages. I have another MDB on this queue which simple takes the message and sticks it in a database to await manual intervention (It could also do things like, for example, send the sys admin an SMS or email). This failed messages MDB does wrap everything in the onMessage in a catch(Throwable) which just logs the error; since the entire prupose of this bean is as a last resort in the event of failures. Rich On Thursday 26 September 2002 01:38 am, Sachin Pandey wrote: > Hi, > > I want to know what's the best way of handling RuntimeExceptions in > Message Driven Beans. Currently I have an MDB listening to a Queue. The > acknowledgement mode is set to AUTO_ACKNOWLEDGE. If the onMessage() > throws a RuntimeException will the app server retry the delivery of the > message. I guess that's what is happening currently with my application. > If I catch the base class Exception it works fine. I am not sure if this > is the right way to do it though? > > Using JBoss 2.4.4 (JBossMQ). > Thanks for any suggestions. > > Sachin Pandey > NUIX Pty Ltd > Level 8, 143 York Street, > Sydney 2000 > Phone: (02) 92839010 > Fax: (02) 92839020 > > Disclaimer: > This message is intended only for the named recipient. If you are not > the intended recipient you are notified that disclosing,copying, > distributing or taking any action in reliance on the contents of this > information is strictly prohibited. > ---------------------------------------- Content-Type: text/html; charset="iso-8859-1"; name="Attachment: 1" Content-Transfer-Encoding: quoted-printable Content-Description: ---------------------------------------- ============================================================================== This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. All information is the view of the individual and not necessarily the company. If you are not the intended recipient you are hereby notified that any dissemination, distribution, or copying of this communication and its attachments is strictly prohibited. If you have received this email in error please notify: [EMAIL PROTECTED] ============================================================================== =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff EJB-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".
