mekatoka
mekatoka

Reputation: 283

Spring Batch - Passing Resource Name from MultiResourceItemReader > FlatFileItemReader to StepExecutionListener

I have a Spring Batch job that needs to do the below

I have used the below

What I want to do

Below is my relevant config

<batch:job id="myJob" job-repository="jobRepository">
    <batch:step id="processFiles">
        <batch:tasklet>
            <batch:chunk reader="multiResourceReader" processor="myItemProcessor" writer="myItemWriter" commit-interval="100" />
        </batch:tasklet>
        <batch:listeners>
            <batch:listener ref="myStepListener"/>
        </batch:listeners>                          
    </batch:step>
</batch:job>

Upvotes: 2

Views: 4776

Answers (1)

Luca Basso Ricci
Luca Basso Ricci

Reputation: 18413

This scenario is similar to this one.
I'm not a fan of first solution because is too messy and file rename is "hidden" into java code and can't be easily detected from job's xml definition.
I prefer solution #2: IMO success/error conditions are easy to check and step flow is more cleaner and well separated.
Get your consideration, I hope my advices will help.

Upvotes: 0

Related Questions