wildfly 10 final:调用计时器超时时出错 [英] wildfly 10 final: Error invoking timeout for timer

查看:55
本文介绍了wildfly 10 final:调用计时器超时时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有

@Stateless
public class TimerMonitoraggioDatabase {

    @Schedule(hour="5", minute="10", dayOfWeek="Mon-Fri",
      dayOfMonth="*", month="*", year="*", info="MyTimer", persistent=false)
    private void scheduledTimeout(final Timer t) {

但是如果活动超过 10 分钟,我就会出现这个错误(第一个问题):

but if the activity exceeds 10 minutes, i have this error (first problem):

2017-03-20 05:20:51,097 WARN [com.arjuna.ats.arjuna](EJB 默认 -1)ARJUNA012077:中止调用已经中止的原子操作0:ffff0a93a0e9:-c2465a:58cbcab4:37e3 2017-03-20 05:20:51,099 错误[org.jboss.as.ejb3.timer](EJB 默认 - 1)WFLYEJB0020:错误调用定时器超时:[id=e2ecbbbf-f339-431d-a031-4f02ea8f67fbtimedObjectId=Utopia-ear.Utopia-ejb.TimerMonitoraggioDatabase自动计时器?:真持久?:假timerService=org.jboss.as.ejb3.timerservice.TimerServiceImpl@188c2824initialExpiration=null intervalDuration(以毫秒为单位)=0nextExpiration=Tue Mar 21 05:10:00 CET 2017 timerState=IN_TIMEOUTinfo=MyTimer]: javax.ejb.EJBTransactionRolledbackException:事务回滚在 org.jboss.as.ejb3.tx.CMTTxInterceptor.handleEndTransactionException(CMTTxInterceptor.java:137)在 org.jboss.as.ejb3.tx.CMTTxInterceptor.endTransaction(CMTTxInterceptor.java:117)

2017-03-20 05:20:51,097 WARN [com.arjuna.ats.arjuna] (EJB default - 1) ARJUNA012077: Abort called on already aborted atomic action 0:ffff0a93a0e9:-c2465a:58cbcab4:37e3 2017-03-20 05:20:51,099 ERROR [org.jboss.as.ejb3.timer] (EJB default - 1) WFLYEJB0020: Error invoking timeout for timer: [id=e2ecbbbf-f339-431d-a031-4f02ea8f67fb timedObjectId=Utopia-ear.Utopia-ejb.TimerMonitoraggioDatabase auto-timer?:true persistent?:false timerService=org.jboss.as.ejb3.timerservice.TimerServiceImpl@188c2824 initialExpiration=null intervalDuration(in milli sec)=0 nextExpiration=Tue Mar 21 05:10:00 CET 2017 timerState=IN_TIMEOUT info=MyTimer]: javax.ejb.EJBTransactionRolledbackException: Transaction rolled back at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleEndTransactionException(CMTTxInterceptor.java:137) at org.jboss.as.ejb3.tx.CMTTxInterceptor.endTransaction(CMTTxInterceptor.java:117)

然后再次启动计时器(第二个问题?)而不会在 10 分钟结束时抛出异常

and then starts the timer again (second problem ?) without throw the excption at the end of 10 minutes

推荐答案

我确实在使用 Wildfly 10 时遇到了同样的问题.

I did have the same problem with Wildfly 10.

由于@Schedule 只是将隐式 EJB 计时器与 @Timeout 方法打包的一种简短而简单的方法,因此所有其他 EJB 计时器限制都适用.

Since @Schedule is just a short and easy way to package an implicit EJB Timer with a @Timeout method, all other EJB Timer restrictions apply.

我不是 EJB 专家,但似乎有一个默认超时,当 @Schedule 方法预计完成时 - 这似乎很短(即只有几分钟).此外 - 根据经验证据 - 看起来如果达到超时,它会尝试再次触发该方法(因此在第一次终止后第二次运行).

I am no expert on EJB, but it seems that there is a default timeout, when the @Schedule method is expected to finish - which seems quite short (i.e. mere minutes). Additionally - from empirical evidence - it looks like if the timout is reached, it tries to trigger the method again (hence the second run after the first terminates).

我读到你可以直接在 JBoss 中配置默认​​超时,但这对我来说不是选择 - 所以我没有说服这个领导 (JBoss 事务超时设置?).

I read that you can configure the default timeout directly in JBoss, but this was no option for me - so I did not persue this lead (JBoss transaction timeout setting?).

我所做的是手动设置@Schedule 方法的超时时间.由于 Wildfly 10 默认使用 EJB3,因此请确保使用 EJB3 版本的 TransactionTimeout 注释.

What I did was setting the timeout for the @Schedule method manually. Since Wildfly 10 is using EJB3 as default, make sure that you use the EJB3 version of the TransactionTimeout annotation.

如果尚未隐式,请将以下内容添加到您的 pom.xml 中:

If not already implicit, please add the following to your pom.xml:

<dependency>
    <groupId>org.jboss.ejb3</groupId>
    <artifactId>jboss-ejb3-ext-api</artifactId>
    <version>2.2.0.Final</version>
    <scope>provided</scope>
</dependency>

现在您可以为@Schedule 方法设置超时,例如:

Now you can set a timout just for your @Schedule method, like:

import org.jboss.ejb3.annotation.TransactionTimeout:

@Schedule(hour="5", minute="10", dayOfWeek="Mon-Fri",
      dayOfMonth="*", month="*", year="*", info="MyTimer", persistent=false)
@TransactionTimeout(value = 23, unit = TimeUnit.HOURS)
private void scheduledTimeout(final Timer t) {

这篇关于wildfly 10 final:调用计时器超时时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆