What is the default time for transaction manager? And how to set maximum time(timeout) for transaction?.

Nick Maiorano

The default time depends on your app server. It is usually around 30 seconds. If you are using bean-managed transactions, you can set it like this:

// One of the methods from the SessionBean interface
public void setSessionContext(SessionContext context) throws EJBException
{
sessionContext = context;
}

// Then, when starting a new transaction
UserTransaction userTransaction = sessionContext.getUserTransaction();
userTransaction.setTransactionTimeout(60);
userTransaction.begin();
// do stuff
userTransaction.commit();

If you are using container-managed transactions, this value is set in a app server specific way. Check your app server's deployment descriptor DTD.

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact