Win a copy of OCP Oracle Certified Professional Java SE 11 Developer Practice Tests this week in the OCP forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
Sheriffs:
  • Devaka Cooray
  • paul wheaton
  • Mark Herschberg
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
  • Jj Roberts
Bartenders:
  • Carey Brown
  • salvin francis
  • Piet Souris

Passivation of SB while in transaction

 
Ranch Hand
Posts: 222
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Page 70 of the spec says:

A container may only passivate a session bean instance when the instance is not in a transaction.



If I am not mistaking, this applies to session beans with bean managed transaction demarcation only. Because I think in case of CMT the transaction will not remain open before leaving the method - is this correct?
 
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes correct
 
Ranch Hand
Posts: 284
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes you're correct. BMT is a way to allow beans to manage their transactions by themselves, and especially one aspect of the transaction : it's scope. The scope for CMT tx is the method in which it runs, which means from method start to method end. But BMT allows bean to make smaller and (in case of stateful session beans) longer transactions.

So yes, you're correct.

One thing to keep in mind about BMT, and which is not very much tested (but might be in real exam) : BMT beans do not accept tx from outside, they only use tx they initiated. Off topic here, but while I'm thinking about this, I say it .
 
Ankit Doshi
Ranch Hand
Posts: 222
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good point that one ... Actually I had posted a separate question on this. The question was that - when we say BMT beans do not accept tx from outside - are we talking about the bean scope here or the method scope here? And the reply I got was the bean scope. So I interpret it as a BMT transaction started in one method of the BMT can propogate in the other method of the same BMT bean.
 
Frederic Esnault
Ranch Hand
Posts: 284
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your interpretation is correct
 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think this will apply for session bean's with cmt also. For example Bean A's method funA (has tx attribute Required) is invoking funB(has tx attribute Required) in Bean B.Now even after executing funB it's transaction is not yet over.It has to commit or roll back(This depends on funA of Bean A).In this case i think Bean B will not be passivated.

Am i right???
 
Frederic Esnault
Ranch Hand
Posts: 284
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, after funB() method is over, tx only covers bean A; bean B is not in any transaction anymore at this time, so it may be passivated. Bean A will not be passivated until completion of tx, but bean B is not protected, as it didn't initiate tx; it appeared during tx lifetime, that's all.
 
p anish
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Frederic for the replay.
But i still have doubts on it.The scenario can be like this:-
C was A's client, for A c is has initiated the tx and A will not be passivated before C commit's .

For B, A is client who has initiated the transaction and B will not be passivated befor A commit's.B don't know whether the call was from another bean or a java client.

isn't it???.
 
There's a city wid manhunt for this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic