[英]EJB @Schedule timing out method call
I am using an EJB @Schedule 我正在使用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. 这是失败的,因为我的鳕鱼需要3分钟以上的时间,这是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. 我不想更改standalone.xml,因为它将产生更大的影响。 Is there anyway I can tell JBOSS/JVM to run this as long as it takes and not time out. 无论如何,只要花费时间且不超时,我就能告诉JBOSS / JVM运行它。
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. 如果需要事务处理,请尝试使用org.jboss.ejb3.annotation.TransactionTimeout
包中的TransactionTimeout
注释。
@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)
否则,您可以选择@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.