• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Tx attribute for MDB

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 775
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
permaculture is largely about replacing oil with people. And one tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic