Scheduler on multiple server instances

烂漫一生 提交于 2020-08-10 05:48:09

问题


Hi I have Java scheduler which run on every hour and i have 16 server instances , this will be deployed in all 16 server instances . How i can ensure that these schedulers tasks won't clash each other. We doesn't want to introduce Spring batch .


回答1:


Basically you can follow 2 approaches for that:

  1. Be sure every instance manages its own data (not sharing it with any other one).
  2. Be sure only one instance can access to the information every time.

The first point depends of your own business logic, for the second one there are some tools can help you, with an easy integration with Spring:

Quartz

Shedlock (easier than Quartz but with less functionality)




回答2:


Actually there are some ways.

  1. you can use distributed lock(Ex: hazelcast's distributed lock).

  2. you can use pessimistic lock in database.(Lock table for each request and set status to IN_PROGRESS)

  3. use quartz for scheduling.(Db persistence is necessary)



来源:https://stackoverflow.com/questions/62492285/scheduler-on-multiple-server-instances

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