'How to pass data to next step in a partitioned flow

Let's say there is a partioned flow composed of 2 steps:

<step id="stepmaster">
    <partition partitioner="partitionerExample">
        <handler grid-size="1" task-executor="taskExecutorExample" />
        <step>
            <flow parent="flowExample"/>
        </step>
    </partition>
</step>

<batch:flow id="flowExample">
    <batch:step id="step1" next="step2">
        <tasklet ref="tasklet1"/>
    </batch:step>
    <batch:step id="step2">
        <tasklet ref="tasklet2"/>
    </batch:step>
</batch:flow>

I need to pass data from step1 to step2. I am familiar with passing data to step execution context and then promoting it to job execution context, but this would not work in this particular situation due to parallelism of partitions, which would overwrite each other.

Since partition data is persisted during the entire flow but not after, I thought there might be a "step execution context" of the flow, I have tried to pass data to step execution context without promoting, but I could not retrive data.

Is there any way to pass data from step1 to step2 conserving parallelism? Whether using a specific (flow?) context or changing design.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source