0

I am using spring cloud and have various microservices for an online shopping vendor. Everything is working as expected.

But, I got a requirement where I need to run a cron job over customer's records, get the customer's who's statement date matches the current date and calculate the rate of interest to be paid. This needs to be run every day.

I am confused about how to accommodate this cron job with MS architecture. Do I need to have another server having just this cron job?

spencergibb
  • 24,471
  • 6
  • 69
  • 75
Nitish Bhardwaj
  • 1,113
  • 12
  • 29
  • do you have a service that "own" the domain for this job. In that one way would be to schedule it there. Otherwise you might want to have new service with this responsibility in the system. – Jocke Jun 13 '18 at 20:57
  • I can have a new service with a different domain. But, the microservice generally has the endpoints to be accessible. This service would be just a spring boot app which won't be accessible from any other service. I know that this can be done but just wanted to make sure that is it the right way of doing this. – Nitish Bhardwaj Jun 14 '18 at 01:42

2 Answers2

0

Depending on the platform (eg: cf, k8s..) that you're orchestrating the batch-jobs in SCDF, you could write a simple Quartz based Boot Application that can interact with SCDF's REST endpoints to schedule the Task definitions defined in SCDF.

There are several online literatures on Quartz + Boot solution.

We are also working on a native scheduler integration for Cloud Foundry (via PCF Scheduler). Once it ready, you'd be able to schedule (i.e., cron-expressions) for Tasks from SCDF's Dashboard natively.

Sabby Anandan
  • 5,636
  • 2
  • 12
  • 21
0

As I understand you should have one centralized supervisor of jobs, because multiplied instances can potentially run the same job at the same time. This supervisor can be a microservice, which delegates job execution to other services via rest call or message queue, and wait for result. It means that job supervisor becomes part of infrastructure, like message queue or database.

Marx
  • 804
  • 10
  • 23