Java EE 7自动计时器(EJB Timer)不适用于WildFly 8.1.0 [英] Java EE 7 Automatic Timer (EJB Timer) not working for WildFly 8.1.0

查看:125
本文介绍了Java EE 7自动计时器(EJB Timer)不适用于WildFly 8.1.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注使用定时服务教程来构建一个简单的计划执行。尝试使用自动方法并使用 WildFly 8.1.0 Final

I am following the Using the Timer Service tutorial to build a simple scheduled execution. Trying the automatic approach and using WildFly 8.1.0 Final for it.

会话Bean

@Singleton
@Startup
public class HelloJob {

    private static final Logger logger = Logger.getLogger(HelloJob.class);

    public HelloJob() {
        logger.error(">>> Hello Job Created.");
    }

    @Schedule(second="*")
    public void sayHello() {
        logger.error(">>> Server Hello!");
    }

}

在部署该类被正确实例化打印>>> Hello Job Created。 message,但方法 sayHello()从未被调用。

On deploy the class is properly instantiated printing the >>> Hello Job Created. message, but the method sayHello() is never called.

根据教程, @Schedule(second =*)表示它应该每秒执行一次。

According to the tutorial the @Schedule(second="*") means that it should execute every second.


将属性设置为星号符号(*)表示属性的所有
允许值。

Setting an attribute to an asterisk symbol (*) represents all allowable values for the attribute.

此外,只有有状态的会话bean不被允许用于计时器,我正在使用一个单例,这也是在示例中使用的。

Also only stateful session beans are not allowed for timers, and I am using a singleton, which is also used in the example.


企业bean容器的计时器服务使您能够
为有状态会话bean的
之外的所有类型的企业bean计划定时通知。

The timer service of the enterprise bean container enables you to schedule timed notifications for all types of enterprise beans except for stateful session beans.


推荐答案

使用 @Schedule(second =*,minute =*,hour =*) $ c>。

Use @Schedule(second="*", minute="*", hour="*").

小时和分钟的默认值为0,这可能非常刺激,有效地强制您设置t hese。

the default values for hour and minute are "0" which can be quite irritating and effectively forces you to set these.

这篇关于Java EE 7自动计时器(EJB Timer)不适用于WildFly 8.1.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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