I have a spring boot batch job application which has around 10 jobs(Number may increase based on requirement). I have been trying out Spring cloud data flow server with local server setup for launching and monitoring those jobs.
But the issue I'm facing here is, after the app registration in SCDF, I create the task for the registered app and the single task itself launches all 10 jobs from the application. Though I could see separate job-id's created for each job inside the single task execution, I'm wondering if it's possible to have separate task for each job that's available inside the single jar. If so how can I achieve it?
I need this because few of the job executions relies on the execution status of a job ran previously. Below is my snippet of job class configuration. And several of my jobs would run at different time intervals. So even if'm using cloud foundry or kubernates for scheduling jobs I would be able to schedule on task level only, where the same scheduling intervals would be applied for all jobs. I may not be able to apply different schedules for each job inside the task. I'm not sure about the cloud foundry and kubernates scheduling part, but I guess that's how it'd work.
//Job Config
@Configuration
@EnableBatchProcessing
@EnableTask
public class Job1Loader {
@Bean
public Job loadJob1()
{
return jobBuilderFactory().get("JOb1Loader")
.incrementer(new RunIdIncrementer())
.flow(job01_step01())
.end()
.build();;//return job
}
//Job Config
@Configuration
@EnableBatchProcessing
@EnableTask
public class Job2Loader {
@Bean
public Job loadJob2()
{
return jobBuilderFactory().get("JOb2Loader")
.incrementer(new RunIdIncrementer())
.flow(job02_step01())
.end()
.build();;//return job
}
Same goes for other 8 jobs.
Thanks.
I'm wondering if it's possible to have separate task for each job that's available inside the single jar. If so how can I achieve it?
Even though I do not recommend packaging all jobs in a single jar, nothing prevents you from using this approach with SCDF. You can create a task definition for each job and configure each task with a property to run a specific job, for example:
--spring.batch.job.names=job1