How to run a Scheduled Method in a Cluster for one Node and for All?

有些话、适合烂在心里 提交于 2019-12-03 06:59:20

I faced the exact same issue (need one cluster timer and a per node timer) and came across this question. So, for anyone interested:

If you declare the timer with @Schedule(..., persistent=true), you will get a cluster timer stored in the timer db (which can be migrated)

If you declare the timer with @Schedule(..., persistent=false), you will get a node timer not stored in the timer db (which can't be migrated)

You could look at using JMS. For the method that needs to run on a single node, use a queue and for the ones that need to run on all nodes use a topic.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!