baabul
asked on
I fail setting the transaction timeout in Weblogic 8.1sp5
In my case, I try to use one XA transaction to coordinate multiple databases operation, so I setup multiple XA-style DBPool according to the multiple databases. I set the "Enable XA Transaction Timeout=true" & "XA Transaction Timeout=300" in every XA-style DBPool via Weglogic admin console. But after I restart the server and test my code with it. This exception "Transaction timed out after 31 seconds" thrown by weblogic. Could you advise me how to set the transaction timeout correctly?
ASKER
Hi,
No ejb's in my case. I use the Hibernate(3.1.3) as the data access tier. Actually I create multiple XA-style datasources in weblogic for my different databases, then config these datasources in Hibernate for creating multiple SessionFactories (one factory for one database). Then implement a JTA interceptor for handling the transaction. When a jta method is invoked, my interceptor will capture it and inject jta transaction code before and after its invoking. The pseudocode has been appended in the end for your reference. The UserTransaction got from weblogic will control the whole transaction processing, so I config its timeout in weblogic will affect on my code. But it's not, the exception "Transaction timed out after 31 seconds" is still thrown by weblogic. I don't know how I can handle it, please advise.
Thanks,
Amax
*****my code************
UserTransaction tx = null;
try {
Context ctx = JndiHelper.instance().getC ontext();
String jtstransaction = "javax.transaction.UserTra nsaction";
if(JndiHelper.instance().g etJndiPara m("jta.Use rTransacti on")!=null ){
jtstransaction = JndiHelper.instance().getJ ndiParam(" jta.UserTr ansaction" );
}
tx = (UserTransaction)ctx.looku p(jtstrans action);
tx.begin();
Object retObject = method.invoke(target, args);
tx.commit();
return retObject;
}catch(Exception e){
if(tx!=null){
tx.rollback();
}
throw new Exception(e.getCause());
}
************************
No ejb's in my case. I use the Hibernate(3.1.3) as the data access tier. Actually I create multiple XA-style datasources in weblogic for my different databases, then config these datasources in Hibernate for creating multiple SessionFactories (one factory for one database). Then implement a JTA interceptor for handling the transaction. When a jta method is invoked, my interceptor will capture it and inject jta transaction code before and after its invoking. The pseudocode has been appended in the end for your reference. The UserTransaction got from weblogic will control the whole transaction processing, so I config its timeout in weblogic will affect on my code. But it's not, the exception "Transaction timed out after 31 seconds" is still thrown by weblogic. I don't know how I can handle it, please advise.
Thanks,
Amax
*****my code************
UserTransaction tx = null;
try {
Context ctx = JndiHelper.instance().getC
String jtstransaction = "javax.transaction.UserTra
if(JndiHelper.instance().g
jtstransaction = JndiHelper.instance().getJ
}
tx = (UserTransaction)ctx.looku
tx.begin();
Object retObject = method.invoke(target, args);
tx.commit();
return retObject;
}catch(Exception e){
if(tx!=null){
tx.rollback();
}
throw new Exception(e.getCause());
}
************************
ASKER
All,
I have finished my case, just set the UserTransaction.setTimeout to the seconds I expect.
Thanks,
Amax
I have finished my case, just set the UserTransaction.setTimeout
Thanks,
Amax
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
are you using ejbs ?
Do you managed transaction inside your code, or do you left the container to deal with ?
Emmanuel