0

This is related to Spring Batch Scheduling Problem.

I have 3 UAT servers (UAT1, UAT2 & UAT3). The task is to run the scheduled batch job in UAT3 server only but while I run a batch job by manually hitting the endpoint url, it should run in all 3 servers. We have used old Batch Executor framework approach. We have an endpoint java class for exposing the endpoint url for manual run, executor class for batch run and configured the scheduling using batch-contxt.xml file. As it is a bit tightly coupled, any change is affecting both manual & scheduled run.

How to modify the approach to include the above problem using spring batch concepts?

  • 1
    `This is related to Spring Batch Problem.`: That's rather a job scheduling problem. Spring Batch is not a scheduler and does not provide any scheduling features. It gives you the APIs to launch jobs, but it is up to you to schedule them as needed (either manually, or using a scheduling framework). – Mahmoud Ben Hassine Jan 11 '21 at 13:20

1 Answers1

0

Use separate yaml configurations based on environment profile and control based on a property. For example something like this.

#yaml file
jobs.importXMLJob.enable = true

@Value("${jobs.importXMLJob.enable}")
    private boolean jobXMLEnable;

@Scheduled(cron = "${batch.cron}")
    public void myJob() {
        if (jobXMLEnable) {
         UAT3 Job
      }
}
Rakesh
  • 658
  • 6
  • 15