Hi,
Please read section 18.3.2 of ejb specs which tells you what to do in case of run time exceptions. onMessage should not throw runtime exception. Even if it throws runtime exceptions (due to say connection , jndi) you should generally not handle them. Your application should be prepared to distinguish the redelivered message and normal messages.
 
--Ashwani
 
 
----- Original Message -----
From: "Saurabh Sahai" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, September 26, 2002 7:38 AM
Subject: Re: Handling RuntimeExceptions in MDB

> Sachin,
>
> Like Dimitri said - you should investigate the reason for the
> RuntimeException and fix it.
>
> Depending on you requirements, if you cannot avoid the RuntimeException
> (which should'nt be the case) and need to control message re-delivery, you
> will need to handle the RuntimeException in the onMessage to avoid the
> message from not being acknowledged and subsequently getting redelivered by
> the container.
>
>
>
> ----- Original Message -----
> From: "Sachin Pandey" <
[EMAIL PROTECTED]>
> To: <
[EMAIL PROTECTED]>
> Sent: Thursday, September 26, 2002 11:54 AM
> Subject: Re: Handling RuntimeExceptions in MDB
>
>
> > So should I catch RuntimeExceptions explicitly in my onMessage()
> > implementation.
> > The MDB is using container managed transaction.
> >
> > Cheers
> > 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.
> > ----- Original Message -----
> > From: "Saurabh Sahai" <
[EMAIL PROTECTED]>
> > To: <
[EMAIL PROTECTED]>
> > Sent: Thursday, September 26, 2002 11:54 AM
> > Subject: Re: Handling RuntimeExceptions in MDB
> >
> >
> > > Refer to the EJB 2.1 specs sec 15.4.13 (there will be something similar
> in
> > > the older specs too) ...
> > >
> > > "Message-driven beans should not, in general, throw
> RuntimeExceptions...."
> > >
> > > In case of an MDB using bean managed tx, the container will not
> > acknowldege
> > > the message in case of a RuntimeException and hence the message will be
> > > redelivered. If you handle the exception in the onMessage, the container
> > > will duly acknowledge the message.
> > >
> > > -Saurabh
> > >
> > > ----- Original Message -----
> > > From: "Sachin Pandey" <
[EMAIL PROTECTED]>
> > > To: <
[EMAIL PROTECTED]>
> > > Sent: Thursday, September 26, 2002 11:38 AM
> > > Subject: Handling RuntimeExceptions in MDB
> > >
> > >
> > > 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.
> > >
> > >
> >
> ===========================================================================
> > > 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".
> >
> >
> ===========================================================================
> > 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".
> >
>
> ===========================================================================
> 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".
>

Reply via email to