This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes Message-Driven Bean and Transaction Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Reply Bookmark "Message-Driven Bean and Transaction" Watch "Message-Driven Bean and Transaction" New topic
Author

Message-Driven Bean and Transaction

Cainiao Zou
Ranch Hand

Joined: Mar 03, 2009
Posts: 36
Hi, i'm reading a description about transaction in MDB (the book "Enterprise JavaBeans 3.0" from O'Reilly)



In my opinion, in MDB we shouldn't use the transaction attribute which has a relation with caller/client, because MDB is "message driven", so we just lost some informations about the client. And that's what it should be.

But why Required transaction attribute is allowed here? It will use the old transaction of client if there is one, am I right? And why not RequiredNew, it just create a new transaction no matter the situation of the client.

Is that an error of this book or i don't understand correctly?

thanks
Piotr Nowicki
Ranch Hand

Joined: Jul 13, 2010
Posts: 610

Howdy Cainiao!

I don't think that the transactions in MDB means a transaction between a client/producer and consumer.
The main point of MDB and messaging is to decouple the sender from the receiver, so connecting/synchronizing their transactions is not a valid approach.

I rather think that the MDB transactions take place between a broker (JMS provider) and consumer.

Cheers!


OCP Java SE 6 Programmer, OCM Java SE 6 Developer, OCE Java EE 6 JSPSD, OCE Java EE 6 EJBD, OCE Java EE 6 JPAD, Spring 3.0 Core Professional.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 8146
    
  52

Pedro Kowalski wrote:

I rather think that the MDB transactions take place between a broker (JMS provider) and consumer.


The transaction for a MDB starts from the point the message is delivered to it and spans till the onMessage method completes.

[My Blog] [JavaRanch Journal]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Message-Driven Bean and Transaction
 
Similar Threads
Question on MDB
Transactions questions
MDB's & transaction attributes
Tx attributes for Message-driven beans, HFEJB p500
Message-driven beans and transaction attributes