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

Transactions questions

 
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have read in the book : EJB 3.0 that "Message Driven Beans" can only have two transaction attributes which are :

1- Not Supported
2- Required

I do not understand why in Message Driven Bean I cannot user other transaction attributes such as RequiresNew or Mandatory.

Thanks in advance.
 
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Khaled said:
I do not understand why in Message Driven Bean I cannot user other transaction attributes such as RequiresNew or Mandatory



Mandatory means a transaction is required when the method is invoked.
MDB's have no clients and container invokes the onMessage method, so there is no incoming transaction and hence Mandatory is not permitted.

Requires new means there is an incoming transaction, it is suspended and new transaction is started. Since there is no client there is no incoming client. So RequiredNew makes no sense.
 
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I find this explanations from O'Reilly's book very clear:


Message-driven beans may declare only the NotSupported or Required transaction attribute. The other transaction attributes don't make sense in message-driven beans because they apply to client-initiated transactions. The Supports, RequiresNew, Mandatory, and Never attributes are all relative to the transaction context of the client. For example, the Mandatory attribute requires the client to have a transaction in progress before calling the enterprise bean. This is meaningless for a message-driven bean, which is decoupled from the client.

The NotSupported transaction attribute indicates that the message will be processed without a transaction. The Required transaction attribute indicates that the message will be processed with a container-initiated transaction.



Regards,
 
Khaled Mahmoud
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I read this explanation for the first time, I thought that "Client" only means an application client and it did not come to my mind that it could be an EJB well. That's why there was a confusion about this explanation.

When reading Amol explanation i thought that it could be another session that could invoke this statement. Exactly this statement made me figure this out


container invokes the onMessage method,



Thank you both for help.
[ August 23, 2007: Message edited by: Khaled Mahmoud ]
 
I've never won anything before. Not even a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic