Reputation: 485
I'm trying to increase the timeout of a transaction in a Java Quarkus application. I already found some old answered questions, but none of them is working for me. The solution that's also mentioned in the official documentation is adding two annotation at method level:
@Transactional()
@TransactionConfiguration(timeout = 360)
public void savePlan( Map< PlantId, CalendarData > aCalendarsMap,
SPScenario aScenario, int aCNumber )
{
FlowPlan plan= createOrGetPlanBase( aScenario, aCNumber );
for( CalendarData calendarData : aCalendarsMap.values() )
{
ConstraintsCalendar calendar = plan.getCalendar( constraintsCalendarData.getPlantUnit() );
if( calendar == null )
{
calendar = plan.createCalendar( constraintsCalendarData.getPlantUnit() );
}
calendar.createConstraints( calendarData.getConstraints() );
em.flush();
em.detach( calendar );
}
}
When this method runs, I get this exception, which can be found in this source code
Changing timeout via @TransactionConfiguration can only be done at the entry level of a transaction
I tried also adding the 2 annotation on top of the method that's calling savePlan(), or also the service class level, no error happens but the timeout increase is not working ( I get a timeout after 1 minute, which is the default one). What already worked for me is increasing the timeout for all the application, by adding this config in the properties.yml file, But for now I want to avoid that.
quarkus:
transaction-manager:
default-transaction-timeout: 360s
One detail about the entity manager flush/detach, it was added to improve the performance, because we had issues with latency and memory (we were using Wildfly before moving to Quarkus recently).
Does anyone know the proper way to increase the timeout of a transaction in a Quarkus application ? Thanks.
Upvotes: 1
Views: 123