Hi there, I am using an MDB and its onMessage function has a TransactionAttributeType set to Required. From within the onMessage function, I call a stateless session bean, all of whose function have TransactionAttributeType set to RequiresNew. From within this session bean, I call another stateless session bean, also with TransactionAttributeType of RequiresNew. Everything is container managed. My question is this. If a message is put on the JMS queue and an MDB takes the message off the queue and starts executing its onMessage function, how many transactions will be created? I have not been able to find a clear answer as to whether or not such nested transactions are supported by Weblogic 10g R3. Any advice would be appreciated. Thanks in advance!
- Posted by: Chris toph
- Posted on: June 12 2009 06:20 EDT
Hi I have implemented such scenarios couple of times, and it works fine, i implemented this in websphere and jboss. In my opinion this scenario is not nested transaction, as with EJB model - container will suspend existing transaction for a Requires New transaction... I read somewhere that in nested transaction model, child transactions are started while parent transactions are still active - which is btw prohibited by EJB specs. There will be 3 transactions - T1 - Spawned by MDB T2 - spawned by session bean 1 T3 - spawned by session bean 2 Thanks Rajiv
Hi Rajiv thank you very much for your answer, I appreciate it. I didn't know that the transactions work like that and that they are thus not really nested. What you say makes sense to me. I then have another question though :-) Take the same scenario as above. In the function of session bean 2, I instantiate a new object (which is annotated as an entity) and call the entity manager's persist function on the new entity object. What I am observing is as follows: If the beans have the following transaction attributes MDB - requires new session bean 1 - required session bean 2 - required, then the newly persisted entity is indeed found in my database at the end of the MDBs onMessage function. If however the beans have the following transaction attributes MDB - requires new session bean 1 - required session bean 2 - requires new the table in the database is empty at the end of the MDBs onMessage function, using the exact same code as before. This is strange to me... any ideas why this could be happening? Thanks again for any advice!