javajsr352

Multiple ItemProcessors in JSR-352


I am referring to Java Batch as specified in JSR-352. The implementation I use is JBeret.

To more flexibly juggle existing code for chunk based batchlet execution, I'd like to chain multiple item processors such that the output of one is the input of the next. The whole chunk step should look like

ItemReader -> ItemProcessor1 -> ItemProcessor2 -> ... -> ItemWriter

Knowing that JSR-352 only allows one ItemProcessor per step I am now wondering if it were possible to create a CompoundItemProcessor that manages the chain of other ItemProcessors. And while I try to implement it, the instantiation seems a challenge as I would not know how to define parameters that can efficiently be routed to the single ItemProcessors.

Are parameters strictly Strings? Numbers? Can they be complex objects? As I am trying to nest processors, is there some way to nest parameters? Any idea is welcome.


Solution

  • Trying to implement a compound item processor that can just call multiple others I ran into configuration issues. Configuring the sub-processors is a hurdle if all that you have is strings on the compound level. As described here, the same symptoms apply to ItemReader when you try to nest them.

    But then 'difficult' is not impossible, and by chance I bumped into the Apache Batchee ChainProcessor.

    So not only have others experienced the same problem, they thought about it and came to completely different results.