MDB is not really a good solution for stuff like this. MDB is basically a
push from the provider to a bean with out any insight as to the state of the
application short of the available server sessions.
A better approache would be a pull from the provider from the application
layer which would simply hand off the message to a session bean which
implementes MessageListener.
The pulling thread could then use application specific logic to determine if
it should pull off a message.
I like the idea of a reject queue or something like that for MDB though.
--jason
On Thu, 16 Aug 2001, Scott M Stark wrote:
> The mdb does not have to thrown an exception to cause this behavior. If it
> interacts with another ejb that is transacted and that bean rolls the
> transaction
> back the msg will get redeliverd. I have a trivally test case that causes
> the problem:
>
> public void onMessage(Message m)
> {
> try
> {
> IHome home = ...;
> home.findByPrimaryKey(null);
> }
> catch(Throwable t)
> {
> }
> }
>
> The tx will be rolled back by the failed findByPrimaryKey() call which will
> cause the msg
> to be redelivered and were spinning.
>
> ----- Original Message -----
> From: "Hiram Chirino" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, August 16, 2001 6:28 PM
> Subject: Re: [JBoss-dev] Improving MDB behavior in the presence of delivery
> failures
>
>
> >
> > Per spec the MDB should not be throwing any exceptions.. This would mean
> > that it's thier responsibility to put the message to a 'rejected' queue.
> >
> > But I think that is the best solution would be to allow the MDB to be
> > configured with the 'rejected' queue in it's deployment descriptor. I
> know
> > that not everybody will enclose thier MDB code in try { } catch (Throable
> e)
> > {}
> >
> >
> > Regards,
> > Hiarm
> >
> > >From: "Scott M Stark" <[EMAIL PROTECTED]>
> > >Reply-To: [EMAIL PROTECTED]
> > >To: <[EMAIL PROTECTED]>
> > >Subject: [JBoss-dev] Improving MDB behavior in the presence of delivery
> > >failures
> > >Date: Thu, 16 Aug 2001 18:22:23 -0700
> > >
> > >Right now there are any number of ways to cause JBoss to spin in a tight
> > >loop
> > >trying to deliver a transacted msg to an mdb due to a problem with either
> > >the msg or mdb code that either causes an exception thrown from
> onMessage()
> > >or the tx to be rolled back. A trivial example of the latter is to have
> an
> > >mdb
> > >do a findByPrimaryKey() using a key from the msg that happens to be null.
> > >
> > >One solution would be to have the mdb container fail such msgs after so
> > >many delivery attempts. On failure, the msg along with the exception
> would
> > >be placed into a error queue associated with the container. An admin
> would
> > >have to pull the msg off, fix any data problems and then place the msg
> > >back onto the mdb queue/topic for redelivery.
> > >
> > >Are there any better ways to handle this?
> > >
> > >
> > >
> > >_______________________________________________
> > >Jboss-development mailing list
> > >[EMAIL PROTECTED]
> > >http://lists.sourceforge.net/lists/listinfo/jboss-development
> >
> >
> > _________________________________________________________________
> > Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
> >
> >
> > _______________________________________________
> > Jboss-development mailing list
> > [EMAIL PROTECTED]
> > http://lists.sourceforge.net/lists/listinfo/jboss-development
> >
>
>
> _______________________________________________
> Jboss-development mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/lists/listinfo/jboss-development
>
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development