Java Schedule a task for single execution

89 Views Asked by At

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);

Any suggestions will be welcome.

1

There are 1 best solutions below

0
On

One idea: Instead of trying to get the cron/timer tool to only execute once, you could schedule the task on all of the nodes, but then use some kind of coordination between nodes to decide which one will actually execute the task.