As a newbie to the Batch Processing API (JSR-352), I have some difficulties modeling the following (simplified) scenario:
- Suppose we have a
Batchletthat produces a dynamic set of files in a firststep. - In a second
step, all these files must be processed individually inchunks (viaItemReader,ItemProcessorandItemWriter) resulting in a new set of files. - In a third
stepthese new files need to be packaged in one large archive.
I couldn't find a way to define the second step because the specification doesn't seem to provide a loop construct (and in my understanding partition, split and flow only work for a set with a known fixed size).
How could a job xml definition look like? Do I have to give up on the idea of chunking in the second step or do I have to divide the task into multiple jobs? Is there another option?
You can use a PartitionMapper to programmatically define a dynamic number of partitions for a partitioned step.
The mapper needs to create a PartitionPlan object which sets the number of partitions and provides partition-specific properties for each.
Your mapper's mapPartitions() method will look something like this outline:
And then you can reference the partition-specific property values in substitution like this (which is the same way you reference statically-defined partition properties):