0
votes

I am using spring-batch to copy data from one datasource into another. I have multiple xml files with the defintions of the necessary steps and jobs. They are all pretty similar with a lot of duplicate "code". The only differences are ususally the SQL that selects data from the first datasource and the name of the table where the data is inserted in the second datasource.

I would like to create a parent job that consists of the steps and jobs to copy the data and only takes the SQL and the name of the target table as a parameter. I know, i can set a parent job with the 'parent' attribute:

<batch:job id="copyDataJob1" parent="AbstractCopyJob">
    ...
</batch>

But how can I pass and use these parameters in the definition of the parent job?

1
how are you launching the jobs?Yazan Jaber
Why not use the same job with a different job-parameter as key to change the pool of queries/tables to manage?Luca Basso Ricci

1 Answers

0
votes

Steps within a job definition are not inherited (we wouldn't know where to put them in the new flow) so what you're attempting isn't 100% possible. What you can do, however, is define a parent step (or steps) that you define the appropriate pieces for. From there, each job definition you create, would be just a list of steps extending the parent.

That being said, if the SQL in a reader is all that changes from run to run, why not just have a single job definition, define your reader as step scoped and use a job parameter to pass in the SQL?