简体   繁体   中英

EJB @Schedule timing out method call

I am using an EJB @Schedule

@Schedule(hour:"18")
someProcess(){

//this code takes 10 minutes
}

This is failing because my cod takes > 3 minutes which is the default time in my Jboss. Is there anyway I can handle this programmatically ? I do not want to change the standalone.xml becuase that will have a bigger impact. Is there anyway I can tell JBOSS/JVM to run this as long as it takes and not time out.

Change your code to:

@TransactionAttribute(NOT_SUPPORTED)
@Schedule(hour:"18")
void someProcess(){

      //this code takes 10 minutes

}

in order to prevent transaction timeout from occurring.

Try TransactionTimeout annotation from org.jboss.ejb3.annotation.TransactionTimeout package if you need transactional job.

@TransactionTimeout(unit = TimeUnit.MINUTES, value = 10)
@Schedule(year = "*", minute = "0", hour = "18", dayOfMonth = "*")
public void performHeavyJob(){
    // hmmm...Heavy Code.
}

Otherwise you can opt @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM