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

Transaction(open across multiple)

 
Yi Si
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Spec. say "BMT can be used to keey a transaction open across multiple invocation to a stateful method bean.".
but I can not understand purpose of this rule.Can somebody show me a
example?
 
Shafique Razzaque
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The 'purpose of the Rule' is to allow the Stateful Bean using BMT to execute multiple business methods in the same transaction.
Consider a scenario:
A stateful session Bean uses BMT. Client calls multiple methods, method_1() , method_2(), .. method_n() which are to be executed in the same transaction.
Flow:
1. Client invokes the bean's method_1().
2. method_1() has BMT demarcation to start a transaction T_1 using UserTransaction.begin().
3. method_1() returns without completing transaction T_1.
4. method_2() is called next, since T_1 is already associated with the instance the method executes in transaction T_1.
5. method_2() returns without completing the transaction.
6. method_n() is the last to be called, it continues in T_1, and eventually commits/rollbacks the transaction T_1 using UserTransaction.commit().
Conditions:
a. If method_2() ( or method_n() ) attempts to open a new transaction in the above scenario, when T_1 is already open and has not been commited, it will throw javax.transaction.NotSupportedException in the UserTransaction.begin() method.
b. Stateless Beans are however required to complete the transaction before the business method returns (unlike Stateful Session Beans).
Note: If the client calls the method_1() in his own transaction , the client's transaction is always suspended before BMT starts its own transactions.
I hope it answers your question.
Regards,
Shafique.
[ March 03, 2004: Message edited by: Shafique Razzaque ]
 
Yi Si
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
got it. thank you very much.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic