• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

EJB MDB "REQUIRED" TX Attribute

 
Ranch Hand
Posts: 138
Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I am going through an EJB book and came across this statement.
A Message Driven Bean can use 'REQUIRED' tx attribute for its onMessage method.

What my interpretation is:
If some message is delivered in a queue by some client method, and that method has initiated some transaction.
Now 'REQUIRED' attribute applied to MDB means that the client producing the message should have some transaction initiated.
Else, MDB would create a new one.

Now, only when the client tx is successful, the MDB will be motified about the message in the queue, which means the client tx is already completed when MDB 'onMessage' method is called.
So, how does 'REQUIRED' tx fit here?
 
Bartender
Posts: 1104
10
Netbeans IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your interpretation is incorrect. You have to remember that with queues, the processing is asynchronous. The client can send the message to the queue and it will be delivered. But, when the MDB takes it up for processing is in the control of the server. It may be immediate or an hour later. Basically, there is no direct link between the client and the MDB. So, it is obvious that a transaction cannot span this entire communication.

If a MDB has a @Required transaction attribute, that would mean that the code in the method runs under a transaction. For example, the MDB might process the message and write it to a DB - so, you can wrap this in a transaction.
 
Prajakta Acharya
Ranch Hand
Posts: 138
Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, I got it now. Client tx will anyway be not related to MDB transaction. @Required would only mean that MDB creates a new transaction.
Thank you so mych for your explaination.
 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1104
10
Netbeans IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sure, you're welcome.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic