如何在Glassfish 4.1.1中更改EJB事务超时? [英] How to change EJB transaction timeout in Glassfish 4.1.1?

查看:134
本文介绍了如何在Glassfish 4.1.1中更改EJB事务超时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Glassfish中,EJB事务超时默认设置为120秒,我想更改此值.

我知道可以通过在glassfish-ejb-jar.xml中定义"cmt-time-in-seconds"参数来更改它,但是我将Web模块与EJB类一起使用,并使用glassfish-web.xml分别.

有什么办法可以更改超时时间?

In Glassfish the EJB transaction timeout is set to 120 seconds by default, and I want to change this value.

I know that it can be changed by defining the "cmt-timeout-in-seconds" param in the glassfish-ejb-jar.xml, but I use the Web module with EJB classes in it, and use the glassfish-web.xml respectively.

Is there any way to change the timeout?

UPD:

事务服务设置中的事务超时值无效.

UPD:

The Transaction Timeout value in the Transaction Service settings has no effect.

@Schedule(minute = "*/5", hour = "*", persistent = false)
public void doSomething() {
    log.info("Started");
    try {
        Thread.sleep(1000 * 119);
    } catch (InterruptedException ex) {
        log.info("Interrupted", ex);
    }
    log.info("Finished");
}

上面的代码可以正常工作.但是如果将睡眠时间更改为121秒

The code above works fine. But if to change the sleep time to 121 seconds

Thread.sleep(1000 * 121);

在GF服务器日志中,我看到一个错误:

in the GF Server log I see an error:

Warning:   EJB5123:Rolling back timed out transaction

此后,该服务再次调用doSomething()方法,并且在2分钟内我再次看到错误:

After this, the service invokes the doSomething() method once more, and in 2 minutes I see errors again:

Warning:   EJB5123: Rolling back timed out transaction
Info:   EJB5119:Expunging timer [...] after [2] failed deliveries

并且该服务不再调用doSomething()方法.

and the service doesn't invoke the doSomething() method anymore.

推荐答案

即使是Web模块,也要添加sun-ejb-jar.xml(或glassfish-ejb-jar.xml):

Even if it's a web module, add the sun-ejb-jar.xml (or glassfish-ejb-jar.xml):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 EJB 3.0//EN" "http://www.sun.com/software/appserver/dtds/sun-ejb-jar_3_0-0.dtd">
<sun-ejb-jar>
    <enterprise-beans>
         <ejb>
            <ejb-name>YourEjbName</ejb-name>
            <cmt-timeout-in-seconds>1200</cmt-timeout-in-seconds>
         </ejb>
    </enterprise-beans>
</sun-ejb-jar>

这篇关于如何在Glassfish 4.1.1中更改EJB事务超时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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