'how can I make sure only 1 instance of the function is running at any given time?
I am writing a spring-boot application with @Scheduled or Shedlock which runs a function every 10 mins. That function may take varying times depending on the load, 10 min or maybe even 20 mins.
I want to make sure that the @Scheduled or Shedlock doesn't run another instance of that function while the current function is actively running. What's the best way of doing that?
I don't have a database, but I was thinking I can use DynamoDB or Redis Cache. One issue I can see is that if let's say the application crashes in the middle of the job, it will still have the cache entry. Sure, I can add a TTL to the cache entry, but then the app will still have to wait till the TTL expires.
Is there a better way to handle this situation?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
