Brian Dolan
Brian Dolan

Reputation: 3136

Spring Batch with multiple jobs and xml files

Is it possible to have multiple job definitions in Spring Batch? For instance, jobA.xml and jobB.xml both containing well-formed jobs. I want to execute jobA under some conditions and jobB under others. I cannot seem to find a way to identify a Job or a Job Launcher with a specific pre-defined job.

Perhaps I'm mis-understanding the technology. Please help if you have a moment.

Thanks! b

Upvotes: 3

Views: 5150

Answers (1)

user2167412
user2167412

Reputation: 46

Nested Jobs can be easily defined in the xml, say you have a child job ...

<job id="childJob" .....
</job>

You can have a parent job referencing the childJob ...

<job id="parentJob" ...>
  <step id="step1" ..>
   <job ref="childJob" />
  </step>
</job>

If you don't want to have all the jobs in one xml, properly you can use partition your jobs into multiple xml and use the import such as the following in the parent jobs xml.

<import resource="child-jobs.xml" />

Upvotes: 3

Related Questions