• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Tx attributes for Message-driven beans, HFEJB p500

 
Suman Sarker
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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--
 
I don't get it. A whale wearing overalls? How does that even work? It's like a tiny ad wearing overalls.
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic