I see. Thanks for the details.
When adding the setRollbackOnly, I got the following error message in the
log: setRollbackOnly must only be called in the context of a transaction
(EJB 2.0 - 15.5.1).
I know why I am getting this, since my MDB deployment has the following
settings:
Ejb-jar.xml
============
<transaction-type>Container</transaction-type>
<acknowledge-mode>Auto-acknowledge</acknowledge-mode>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>CustomerService_CustomerMsg</ejb-name>
<method-name>onMessage</method-name>
</method>
<trans-attribute>NotSupported</trans-attribute>
</container-transaction>
</assembly-descriptor>
Jboss.xml
==========
<xa-connection>false</xa-connection>
But somehow, with such settings, when an exception is thrown from onMessage,
there is still some kind of a transaction rollback that is done since my
messages are not lost and are going back to the queue.
Thomas
-----Original Message-----
From: Adrian Brock [mailto:[EMAIL PROTECTED]
Sent: Monday, December 22, 2003 4:58 PM
To: [EMAIL PROTECTED]
Subject: Re: [JBoss-user] MDB EJB life-cycle
On Mon, 2003-12-22 at 21:29, [EMAIL PROTECTED] wrote:
> I am looking for some information as when ejbRemove is called on a
> message driven bean. I understand the fact that there is a JMS session
> pool that is created to read JMS messages of the queue and this pool
> size is 15 by default. For each of those session, one MDB instance is
> created. Can more MDB instances be created and the previously created
> one removed (with ejbRemove called on it)?
> If yes, I suppose there is some kind of a pool of MDB instances. Where can
I
> configure this pool?
>
> We have one of our test where exceptions are thrown from the onMessage
> of the MDB. In this case, it seems that new MDB instances are created,
> but the old ones do not seem to go away (or at least, ejbRemove does
> not seem to be called).
>
> Thanks in advance for any help.
>
It is a bug to throw an uncaught exception of any type from onMessage().
onMessage() is part of the JMS spec NOT the EJB spec.
I wish I could delete all the examples on the internet that throw new
EJBException() to force a transaction rollback. Use
messageDrivenContext.setRollbackOnly()
The only exception I can see to this rule is if you have no idea what is
going on and want the bean instance discarded,
e.g. a NullPointerException.
Whether you leak the NullPointerException or not, you've got
a bug to fix.
If you read the ejb spec it explicity states that ejbRemove is not invoked
in the event of a crash by the container or an unhandled throwable leaked
from onMessage(). It leaves it as an application problem how any resources
allocated in ejbCreate() are cleaned up in that case.
See "Missed ejbRemove calls".
It is much more scalable to allocate expensive resources
from a pool in onMessage() than it is for each MDB instance
to hold its own copy.
Regards,
Adrian
> Thomas
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: IBM Linux Tutorials. Become an
> expert in LINUX or just sharpen your skills. Sign up for IBM's Free
> Linux Tutorials. Learn everything from the bash shell to sys admin.
> Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jboss-user
--
xxxxxxxxxxxxxxxxxxxxxxxx
Adrian Brock
Director of Support
Back Office
JBoss Group, LLC
xxxxxxxxxxxxxxxxxxxxxxxx
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills. Sign up for IBM's
Free Linux Tutorials. Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills. Sign up for IBM's
Free Linux Tutorials. Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user