This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

MessageDrivenBean - getUserTransaction?

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On page 320 of the specs, it states:

For BMT, ejbCreate/ejbRemove have access to getUseTransaction. Does this mean it can execute methods within the UserTransaction interface. If so, why does it list UserTransaction methods for ejbCreate/ejbRemove - similiar to onMessage(). That is, onMessage states getUserTransaction() and UserTransaction methods.
[ November 09, 2004: Message edited by: Billy Hickory ]
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My understanding:
ejbRemove/ejbCreate in MDB is not triggered by client (no client in MDB). It's up to the container to determine when to use these callbacks. Therefore there is no meaningful transaction context during ejbCreate/ejbRemove, hense you cannot call getUserTransaction.

Yi
SCJP
SCBCD
 
Billy Hickory
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
True..the client can not call these methods - actually the container calls these methods. However, the provider can put code in these methods. On page 320 of the spec, it does state you can call getUserTransaction() method in ejbCreate and ejbRemove. If so, you have the Usertransaction object, which means you should be able to call the UserTransaction methods.

I believe it is an error in the specs. That is, if you have access to getUserTransaction(), you should be able to call the UserTransaction methods.
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
UserTransaction for MDB has nothing to do with the user who sent message. UserTransaction is a reference to Transaction Manager. On ejbCreate() bean stores a reference to Transaction Manager and then later multiple times uses it to begin and commit transaction in onMessage() method. It is more efficient then obtaining UserTransaction every time when container invokes bean onMessage() method.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!