Glassfish服务器上的自动EJB定时器不触发 [英] Automatic EJB Timer on Glassfish Server not triggering
问题描述
@Stateless
public class SessionTimerBean {
public SessionTimerBean(){
System.out.println(Constructor Called);
}
@Schedule(second =* / 10,minute =*,hour =*)
public void scheduleTimer(final Timer t){
System.out.println(Timer Called);
}
}
当我启动Glassfish时,调试信息似乎表明它识别EJB定时器注释,并且bean的构造方法在启动时被调用。但是计时器方法本身似乎从来没有被触发过。
有其他人有这个问题吗?有没有其他配置我失踪了?
提前感谢
根据规范,按照惯例执行:
定时器服务用于对长期业务
进程进行建模。计时器可以在容器崩溃,服务器关闭以及向其注册的企业bean
的
激活/钝化和加载/存储周期中幸存下来。这些持久的担保可以在每个定时器的基础上
被禁用。
Aksel展示了如何禁用持久保证。 glassfish服务器使用其默认数据库来持久定时器(请查看这里)。我可以想象它没有开始运行,因为计时器不起作用。使用以下命令启动它:
asadmin start-database
So I'm running a Java EAR application on a Glassfish 3.1. I created a stateless session bean with a single annotated timer function in my EJB Module. I don't have the exact code but it looks something like this:
@Stateless
public class SessionTimerBean {
public SessionTimerBean(){
System.out.println("Constructor Called");
}
@Schedule(second="*/10", minute="*", hour="*")
public void scheduleTimer(final Timer t) {
System.out.println("Timer Called");
}
}
When I launch Glassfish the debug info seems to indicate that it recognizes the EJB timer annotations and the constructor method for the bean does get called upon launch. But the timer method itself never seems to get triggered at any point.
Has anyone else had this issue? Is there some other configuration I'm missing?
Thanks in advance.
According to the spec, Timers are persistent by convention:
The timer service is intended for the modelling of long-lived business processes. Timers survive container crashes, server shutdown, and the activation/passivation and load/store cycles of the enterprise beans that are registered with them. These persistent guarantees can optionally be disabled on a per-timer basis.
Aksel demonstrated how persistent guarantees can be disabled. The glassfish server uses its default database for persisting its timers (take a look here). I could imagine that it was not up and running and because of that the timers did not work. Use the following command to start it:
asadmin start-database
这篇关于Glassfish服务器上的自动EJB定时器不触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!