Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tx attributes for Message-driven beans, HFEJB p500

 
Suman Sarker
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Bang on the right side of HFEJB page 500, says that a message driven bean can only use either Required or NotSupported for the transaction attribute of its onMessage() method. The reason why RequiesNew cannot be used is there will never be a pre-existing transaction.

But I still dont understand why RequiresNew cannot be used. Because Required and RequiresNew both starts a new transaction when there is no pre-existing transaction.

Can someone plz clarify this?

Regards
Suman
[ May 23, 2004: Message edited by: Suman Sarker ]
 
james edwin
Ranch Hand
Posts: 393
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Quote
"Required and RequiresNew both starts a new transaction when there is no pre-existing transaction.".

Not above is not true.

Required attribute will only start new transaction when there is no transaction started from the client side Whereas RequiresNew will always start new transaction context whether client already started transaction context or not.

Summary is as follows:-

Required -> New transaction will be started for if the client is not
running in transaction . If client is running in
transaction,then same will continue,
Method A (No transaction) -------------> Method B (required)
Then it will run in tx B

Method A (TX A ) -------------> Method B (required)
Then it will run in tx A


Requires New -> New transaction will be started whether client is
running in transaction or not.
Method A (No transaction) -------------> Method B (Requires NEW)
it will start new tx B
Method A (tx A) -------------> Method B (Requires NEW)
Even then it start new tx B


I hope above is clear...

Regards,

James
 
Suman Sarker
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi James,
The thing that I do not understand is why I cannot use RequiresNew as a tx attribute for Message Driven Bean. The book says I cannot use it because there will never be a pre-existing transaction.
Now, If there is no transaction present at the moment of onMessage() method call, both the attributes (Required and RequiresNew) are capable of starting a new transaction.
So, Why can I not use RequiresNew when we know that MDB does not need a pre-exisiting transaction?

Any help will be highly appreciated.

Regards
Suman
[ May 24, 2004: Message edited by: Suman Sarker ]
 
Dale Seng
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The main reason is just what my Dad used to say: "cuz I said so!"

The spec developers figured, they needed only to cover a situation where it needs a transaction or doesn't. So they thought "Which one should we use for 'needs one'.... Which one should we use for 'doesn't need one'". Done. Maybe somebody argued for having more possibilities, but if they did, they got shot down.

--Dale--
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic