1

I have a spring-boot application, which takes request from users and save data in db.

There are certain integration calls need with the data saved. So I thought a scheduler task for every 15 mins which should pick this data and do necessary calls.

But my application is being deployed in AWS EC2 on 2 instances. So this scheduler process will run on both the instances, which will cause duplicate integration calls.

Any suggestions on how this can be achieved to avoid duplicate calls.

I haven't had any code as of now to share.

Please share your thoughts...Thanks.

chmk
  • 57
  • 1
  • 8

1 Answers1

1

It seems a similar question was answered here: Spring Scheduled Task running in clustered environment

My take: 1) Easy - you can move the scheduled process to a separate instance from the ones that service request traffic, and only run it on one instance, a "job server" if you will.

2) Most scalable - have the scheduled task on two instances but they will somehow have to synchronize who is active and who is standby (perhaps with a cache such as AWS Elasticache). Or you can switch over to using Quartz job scheduler with JDBCJobStore persistence, and it can coordinate which of the 2 instances gets to run the job. http://www.quartz-scheduler.org/documentation/quartz-2.x/tutorials/tutorial-lesson-09.html

Michael
  • 556
  • 3
  • 12