• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MessageDrivenBean - getUserTransaction?

 
Billy Hickory
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 ]
 
Yi Zou
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.
 
Victor Larr
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic