• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Transaction from HF Page 497

 
phenix java
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From Page 497 EJB Transaction
2.Which transaction attribute (or attribute) must NOT be used by a message - driven bean?
ANSWER : Mandatory,RequireNew,Support,Never
I suspect how to get those answers. Would you please expain me on detail these answers.

4.Of the six transaction attribute,three of them can be dangerous,with one in particular being EXTREMELY risky. Keeping in mind that the Bean Provider is NOT the one who specifiers the attributes of the bean's methods,which of the six is potentially the most dangerous?
ANSWER:Mandatory & NotSupport are dangerous,Because they throw exceptions,But Support is the riskiest,....because it means at runtime you don't know whether it will run in a transaction or Not
I suspect why this answer is Mandatory & Never.Would you please expain me on detail about Support is riskeist,Why isn't NotSupport Or Never?

Thank a lot for kindly your advice!!!
 
Chengwei Lee
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

2.Which transaction attribute (or attribute) must NOT be used by a message - driven bean?
ANSWER : Mandatory,RequireNew,Support,Never


The reason is stated in the EJB 2.0 specifications page 362, section 17.6.3. These 4 transaction attributes are not meaningful in the case of MDB. Mandatory & Never throws exceptions but we've no clients to handle them. There can never be pre-existing transaction context, hence RequiresNew & Supports are also meaningless.

Of course you could argue that RequiresNew can serve the same purpose as Required but too bad the designer of the specifications chose Required over RequiresNew.


4. Of the six transaction attribute,three of them can be dangerous,with one in particular being EXTREMELY risky. Keeping in mind that the Bean Provider is NOT the one who specifiers the attributes of the bean's methods,which of the six is potentially the most dangerous?
ANSWER:Mandatory & NotSupport are dangerous,Because they throw exceptions,But Support is the riskiest,....because it means at runtime you don't know whether it will run in a transaction or Not
I suspect why this answer is Mandatory & Never.Would you please expain me on detail about Support is riskeist,Why isn't NotSupport Or Never?


For Supports attribute, could you possibly safely still make use of getRollbackOnly & setRollbackOnly methods in your codes? You can't be certain that there'll be a pre-existing context. There can be 1 or there can be none. Supports attribute doesn't care.

Hope these helps.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic