Spring batch best practice regarding data between steps
<p>We have an old codebase which i think can be improved a lot by selecting a good batch processing framework.</p>

<p>I've started experimenting with Spring batch and decided (after reading docs, multiple books and forums about it) that the best way to get a feel of it is to actually use it, so i've redeveloped some of our existing apps to Spring Batch.</p>

<p>Here is the simple app i've redeveloped:</p>

<ul>
<li>Read lines from a table and parse lines to a POJO</li>
<li>If a give criteria is met, ignore the item from the list</li>
<li>Write a file from the parsed list</li>
<li>Upload the file to an FTP</li>
<li>Mark elements of the parsed list as processed in the db if the FTP upload is successful</li>
</ul>

<p>Now, what i've done is i've created a single job with 3 steps:</p>

<p>Step1 is: read lines to POJO(reader, jdbc based in this case), exclude items (processor), write to File (writer). Easy. :)</p>

<p>Step2: tasklet to upload to FTP</p>

<p>Step3: now, this is where i'm in trouble. I need to reused the POJO list from Step1. </p>

<p>My understanding is that i have two options: </p>

<p><strong>1)</strong> either use the StepExecutionContext, save the List there and a ExecutionContextPromotionListener implementation to pass the list between Step1 and Step2 and Step2 and Step3. </p>

<p>or </p>

<p><strong>2)</strong> I use the same reader and processor and use a different writer this time.</p>

<p>I don't really like either approach</p>

<p>1) seems messy and i've read in multiple places that it is not a good practice to put something bigger in this context (my list would hold 5-10000 objects)</p>

<p>2) Seems a waste of resource and again, a bad practice. In this scenario, i could get away with it, but in the case of a more complex reader/processor, it would be a quite bad duplication of work.</p>

<p>What is the best way to do what i'm looking to do?
Am i using Spring Batch correctly here?</p>