'Call an API at scheduled time which can be changed dynamically
I have created an API which will return the list of all events that are upcoming in 24 hours. Now, at the start time of these events I have to schedule and API call which will send notifications to all the user. How can I achieve this using AWS cron or any other service? I am using Spring boot in Java.
Solution 1:[1]
The simplest way without paying anything significant is to use lambda for scheduled events. You can simply call any API from Scheduled Lambda. Scheduling Lambda is straight forward but extremely easy if we use serverless framework. You can setup the lambda with schedule in 10 minutes. A cronjob like format is available to set the schedule.
Reference on how to schedule lambda using sls framework https://www.serverless.com/framework/docs/providers/aws/events/schedule
UPDATE:
When you use Serverless framework it sets up the whole framework for scheduling for you. Scheduling part is actually maintained by CloudWatch Events functionality. You can modify this CloudWatch events dynamically as per your needs.
Reference: https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html
Solution 2:[2]
You can use Timer and TimerTask which java provides. Ref - http://www.java2s.com/Tutorials/Java/Java_Utilities/How_to_use_Java_Timer_and_TimerTask_to_schedule_a_task.htm
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Dhanraj |
