Maintain transaction across threads in a session bean
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Sunday, July 15, 2001 11:29 PM

How can i maintain a single transaction across multiple threads created from a session bean? If someone could through some light on this it will be helpful for me.

Thanks
Hari

Re: Maintain transaction across threads in a session bean

Posted By:   Bozidar_Dangubic  
Posted On:   Friday, August 10, 2001 06:57 AM

threading api is not allowed in ejbs. therefore, you cannot create threads in your session beans and hence you will not need to maintain a single transaction across multiple threads created from a session bean since this is not possible. however, if you are managing a single transaction across multiple business calls, you can do that if you setup you ejbs to manage their own transactions instead of letting container manage them. here is what you can do.




....
businessMethod1()
{
get the UserTransaction from JNDI at "java:comp/UserTransaction"
call .begin() on the user transaction
}
businessMethod2()
{
....
do some stuff here, for example
}
businessMethod3()
{
....
get the UserTransaction from JNDI again
try
{
....
business calls..
.commit() on transaction
}
catch(Exception e)
{
.rollback() on transaction
}
}
About | Sitemap | Contact