Transaction setTimeOut ignored in JTA environment
Asked Answered
I

0

1

We have a problem setting transaction timeout on specific operations, overriding the general timeout in an application with Hibernate 4.2.1 and Jboss 7AS, since we find values set with "setTimeOut" are ignored.

We have a JTA non-CMT persistence unit like this:

<persistence-unit name="ourName" transaction-type="JTA">
  <provider>org.hibernate.ejb.HibernatePersistence</provider>
  <jta-data-source>java:/datasources/ourDataSourceName</jta-data-source>
  <properties>
        <property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory"/>
        <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
        <property name="hibernate.show_sql" value="false" />
        <property name="hibernate.format_sql" value="false" />
  </properties>
</persistence-unit>

Then we declare the persistenceUnit like this:

@PersistenceUnit(unitName="ourName")
private EntityManagerFactory emf;

And get the sessionFactory from it. With such sessionFactory, we open a session and get a transaction into which we set the time-out before beginning it:

session = sessionFactory.openSession ();
tx = session.getTransaction ();
tx.setTimeout (200);
tx.begin ();

In our standalone.xml config file we set the global timeout as (the 10s. displayed value is just for testing, of course):

coordinator-environment enable-statistics="true" default-timeout="10"/>

The result is that no matter the values we set via "setTimeOut", a timeout of 10 seconds always applies.

Anyone out there with ideas of what we are doing wrong would be greatly appreciated!

Thx!

Itin answered 7/10, 2013 at 14:38 Comment(3)
Someone else has a similar issue here with a similar set-up on WebLogic: #10416649Sidra
See second answer to this: #2101955 and let me know if it helps.Sidra
Sorry JoshDM, the second post is about long queries timeout which is not exactly the case. I am rather trying to handle the transaction timeout, where queries may be short but the overall transaction becomes longer than 5 minutes. But thx anyway.Turbinate

© 2022 - 2024 — McMap. All rights reserved.