5

I have an JEE application which runs on a JBOSS EAP 7. There is a long running asynchronous method which does import data into another system. After beeing triggered it runs into transactions problems after 5 minutes which is the JBOSS default transaction timeout. So far so good. I changed the behaviour (pseudo code):

Before:
@Transactional(Required) //which is default
//The whole process takes usually longer than 5 min
void doImport{
 for(n-number of datsets){
   importOneDataSet();
 }
}

After:
@Transactional
void doImport{
 for(n-number of datsets){
   importOneDataSet();
 }
}
...
@Transactional(Requires_New) 
//a new transaction is created and the "outer" is suspended
//to import one dataset is below 5min
void importOneDataSet(){
...
}

I assumed that the outer transaction timeout is stopped when it is paused/suspended but I still run into a transaction timout error after 5 minutes.

So it seems that suspending transactions does not influence its transaction timeout? Is that app server specific our is it defined in the JEE standard? And the third question would be: How would you solve this problem? Don't open the outer transaction? Increase the timeout (only) for that transaction?

It is puzzling that most transaction articles I read doesn't even mention that fact. The only hint regarding that topic was one blog post.

Lonzak
  • 9,334
  • 5
  • 57
  • 88

1 Answers1

2

AFAIK you cant configure what will happen to timeout of outer transaction. Nested transaction will never set timeout on hold of outer transaction. If you dont want to affect outer transaction timeout you should to make your inner transaction asynchronous. This way the method will immediately return and not affect outer tnx timeout. So In your example I would try to make importOneDataSet asychronous. But you should know that if you make it asychronous you cannot keep your full import consistent (The outer transaction cannot rollback work of inner async transactions even if you set tnx type to required transaction manager cannot keep the same transaction open over multiple threads). So if your full import must be consistent or if you have to keep the order of your datasets import the simplest solution will be to increase the tnx timout of you import. If the timeout of your full import is too long (Meaning in case of error you loose too much work) you should divide your big one and only import to smaller chunks of work where you can just repeat a single chunk of work independendly of other chunks in case of error.