简体   繁体   English

Java将任务计划为一次执行

[英]Java Schedule a task for single execution

I need to execute a task in the future, just once. 我将来只需要执行一次任务。 Requirements: - The environment is clustered, so need to take care of competition in the moment that the task gets fired, it cannot execute twice; 要求:-环境是群集的,因此在任务被解雇的那一刻需要注意竞争,它不能执行两次; - The task can be scheduled a month ahead and cannot be just scheduled in memory as soon as the node can be restarted or even destroyed at a certain moments (it's an Amazon Elastick Beanstalk environment); -该任务可以提前一个月进行计划,并且不能在某个时刻可以重新启动甚至销毁节点后立即将其安排在内存中(这是Amazon Elastick Beanstalk环境);

Any suggestions will be welcome. 任何建议都将受到欢迎。

一个想法:您可以尝试在所有节点上安排任务,而不是尝试使cron / timer工具仅执行一次,而是在节点之间使用某种协调方式来确定哪个节点将实际执行任务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM