File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tx attribute for MDB

 
Li Xin
Ranch Hand
Posts: 37
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is known that onMessage in MDB can only be specified as Required or NotSupported, but what about any other method that onMessage invokes? Can we specify other Tx attribute?
Thanks.
 
Janne Karhu
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remember that no other business methods except onMessage(...) can be defined for message driven beans. MDBs do not have home or component interfaces and thus the container is the only "client" calling the method.
You can define additional (public/private what ever) methods to you message driven bean, but they are not known to the container and thus cannot have any tx attributes. Hope this helps!
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think he's asking if the MDB calls methods on other beans, can the other beans use Tx attributes other than Required or NotSupported... I would think the answer to this would be yes.

In this case the MDB is just becoming a client of the other bean, so it doesn't impact the other beans in any way, it would behave just like a regular client call in regards to transactions.
 
Vishwa Kumba
Ranch Hand
Posts: 1066
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Li Xin:
It is known that onMessage in MDB can only be specified as Required or NotSupported, but what about any other method that onMessage invokes? Can we specify other Tx attribute?
Thanks.

For a CMT MDB, there is only one call back method, onMessage().
There could be other private/helper methods defined by the bean developer in the MDB but they inherit the transaction attribute specified from the onMessage() method and are called from the onMessage() method.
For a CMT-MDB there are only 2 cases possible:
Either you have a transaction or you do not have a transaction,
hence only Required and NotSupported are applicable.
 
Reid M. Pinchback
Ranch Hand
Posts: 775
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Agreed. The spec is very clear on CMT MDB options. Section 15.4.7, pages 316-317.
If the bean is specified as using container-managed transaction demarcation, either the Required or the NotSupported transaction attribute must be used. ... stuff about BMT ... If the message receipt is to be part of the transaction, container-managed transaction demarcation with the Required transaction attribute must be used. ... stuff about unspecified transaction context ... There is never a client transaction context available when a message-driven bean is invoked because a transaction context does not flow with a JMS message.

That makes it pretty clear. If the CMT MDB can't get a transaction based on the transaction demarcation of the client, then the only possibilities are to get one from the container (Required) or not to have one at all (NotSupported).
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic