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 propogation

 
sandeep vaid
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,


i have one method in stateless session ejb,i want that method to not to have the transaction for it, But it calls two other methods of same been with diffrent transaction attributs (may be each have required tnx attribute) i repeat in same ejb from where the first method is called. like

in single EJB If i have method

// steteless session ejb starts

//with "Never" as a transaction attribute
pubilc myMethod(){
firstTxn()
secondTxn()
}

//with "required" txn
public firstTxn(){
}

//with "required" txn
public secondTxn(){
}

////ejb ends

client calls myMethod()

i wana know how trxn will propogate in this scenario..


For me in weblogic 8.1 it does not gives any transaction to firstTxn() and secondTxn()

But if i call then with again looking up for home and getting remote/
local interface then making call for firstTxn() and secondTxn() it is working fine.

I wanted to know "Is transaction does not change once it gets first call for it with perticular txn attribut even it calls methods of same ejb with different tnx attributs for method with in it???"




Thanks!!
Sandeep vaid
[ July 15, 2005: Message edited by: sandeep vaid ]
 
sawan parihar
Ranch Hand
Posts: 250
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Sandeep,
The behaviour that you have written is correct. If the methods are in the same ejb the methods firstTxn() and secondTxn() won't run in the transaction. The reason is that the container will add its services only when you will do the lookup of bean. In your case since you already got the EJBObject thats why there is no chance for the container to add its services like running method firstTxn() in transaction .

On the other hand if you do a lookup of the ejb and then call the method then the transaction attribute of required will take effect.

Hope this helps.
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just be aware that at the moment the client call is not in a transaction. But if this were to be changed so that the client call is in a transaction, then the container will throw a RemoteException or EJBException to a remote or local client resspectively. If you do not want this to happen, change the transaction attribute of myMethod to NotSupported. This will cause the container to suspend an incoming transaction, so myMethod will run with an unspecified transaction context.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic