HA-Clustered @Schedule

瀏覽次數:37 次
跳到第一則未讀訊息

Tom Eicher

未讀,
2023年1月16日 下午1:03:352023/1/16
收件者:WildFly
Hello,

I have followed the ha-singleton-service quickstart, and it works nicely.
However, I do have a "housekeeping job" bean method with, like, 
@Schedule(hour = "*", minute = "*/10", second = "0", persistent = false)
that I want to run on one cluster node only, i.e. as/in a HA Singleton.

Now when I move the annotated method to the "SingletonService" class,
(i.e. the org.jboss.msc.Service class registered in the ServiceActivator)
the schedule is never picked up, and the method never runs.
When I leave the method on my @Singleton bean service class, it is scheduled on all cluster nodes.

What would be the right approach here?
Can I "stop" the @Singleton EJB on the passive nodes? Or start inactive and only activate on the active node? 
Can I use @Schedule at all in such an environment?
Or do I have to resort to manually registering an Executor like the QueryingService does, not using TimerService and/or Schedule annotation?

Thanks Cheers Tom.

Paul Ferraro

未讀,
2023年1月17日 上午8:09:072023/1/17
收件者:WildFly
MSC services are not processed by the EJB subsystem - which is why your approach does not work.

I would suggest defining your non-persistent housekeeping timer in a @Startup @Singleton EJB and deploying it on each node as a singleton deployment.
回覆所有人
回覆作者
轉寄
0 則新訊息