I'm trying to add a module in my spring boot project. i want from the module is that it sends message to member automatically 2 days before due date.
Asked
Active
Viewed 1,136 times
-1
-
And your question is? – M. Deinum Feb 05 '20 at 11:58
-
my question is how can i add scheduler to send sms 2 days before using spring boot – Chandra Prakash Runwal Feb 05 '20 at 12:52
-
What have you tried, what didn't work. etc. – M. Deinum Feb 05 '20 at 12:58
-
i didn't tried anything yet cause i'm not understanding the way to perform the action. – Chandra Prakash Runwal Feb 05 '20 at 13:03
-
but with the help of a blog curently i'm trying to get date before 2 days using job scheduler – Chandra Prakash Runwal Feb 05 '20 at 13:04
2 Answers
0
Create a job schedule to pick the 2 days before due date, generate corn expression. prepare the data in JobDataMap and trigger the job. please follow below link for an example https://github.com/callicoder/spring-boot-quartz-scheduler-email-scheduling

Madhu Potana
- 91
- 7
-
but i'm not familiar with quartz and i tried to read from the source you provide but not understand properly.... – Chandra Prakash Runwal Feb 05 '20 at 12:56
0
Spring makes it very easy through cron
Add this to your properties file (for 6/2/2020 at 9)
cron.specificdate=0 0 9 6 2 ? 2020
And
@Scheduled(cron = "${cron.specificdate}")
public void scheduleTask(){
...
}

inquirymind
- 135
- 1
- 11
-
i want to send message everyday , 2 days before due date – Chandra Prakash Runwal Feb 05 '20 at 13:23
-
-
I would control the time window (2 days before the due date, right after the due date) within the method code – inquirymind Feb 05 '20 at 14:11
-
if (LocalDate.now().before(dueDate).minus(2, DAYS) || LocalDate.now().after(dueDate)) return; – inquirymind Feb 05 '20 at 15:09