• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MDB transaction attribute question

 
Meg Adal
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As we know MDB can specify only 2 out of 6 trans. attributes:
1. Required
2. Not supported.

I am little confused here with "Required".

MDB method is not called by client,so in my opinion "Required" and "RequiresNew" (if it was allowed) would behave in the same manner?
i.e. method run in new transaction.

Then why doesn't MDB support "RequiresNew" ?

Thanks in advance.
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The short answer is that this is what the spec says. Sun decided, for whatever reason, to use Required. I never spent any time thinking about it, all you need to do is remember it for the exam.
 
Simon Ingram
Ranch Hand
Posts: 173
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Meg,

Roger's advice is practical and given the nature of this subject, probably sound. It would be nice, though, to understand what the designers had in mind when they made their decision and who knows, perhaps one of them will answer you! For what it is worth, it seems to me that they were writing for the container provider (CP). The CP has a choice between passing messages from the JMS service to the consumer(MDB) either with a transaction or not. If the CP starts in a transaction, Required allows him/her to continue in one. Otherwise NotSupported. RequiresNew is different in that it would end the CPs original transaction and start a new one and from a CP point of view, isolating the MDB part is not what the CP wants.
 
Ana Nava
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Meg, I also had the very same question. But after little bit of thinking this how I convinced myself. There is a subtle difference between them. If you say "Required" then it means that you need a transaction. But it is the container that decides to give you a new one, if one is not present or an existing one, if one is present. But if you say "RequiresNew", you could assume that there is a possibility that you might be given an existing transaction, so you are telling to the container, do not ever me an existing transaction and always give me a new one. In case of MDB there is NO such possibility so in order avoid this ambiguity (the assumption that you might be given an existing one), "RequiresNew" is not an option.
 
Meg Adal
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you all for the reply.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic