You should use 2.0.0.RC1.
Chunk-oriented steps should not store anything to the Job's ExecutionContext until after the step is complete. This is because the only the Step's ExecutionContext is persisted during step execution. Or in other words, if your step fails half way through step1, you'll lose any information you've saved. Always store to the Step's ExecutionContext during processing and use the promotion listener to move the content afterward.
For the tasklet:
Code:
public RepeatStatus execute(StepContribution stepContribution, AttributeAccessor attributeAccessor) {
ExecutionContext jobContext = this.stepExecution.getJobExecution().getExecutionContext();
this.staxEventItemWriter.open(0, false);
for(Object obj : (List)jobContext.get(MY_KEY)) {
this.staxEventItemWriter.write(obj)
}
this.staxEventItemWriter.close()
}
@BeforeStep
public void storeStepExecution(StepExecution stepExecution) {
this.stepExecution = stepExecution;
}
At this point you're making Step2 awfully chunk-oriented-looking, but without the benefits like restartability. Also it's pretty strange to generate a huge object of all your step1 data to be passed to step2. Why not just use a StaxEventItemWriter in step1 to write it out at the same time? Then it would be restartable, cleaner, faster, and use less memory.