Announcement Announcement Module
Collapse
No announcement yet.
Spring Batch 2.2 and conditional flows Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Batch 2.2 and conditional flows

    Hi,

    I'm trying to do something very simple like this:

    Code:
    <step id="parseFile" parent="parseFileStep">
        <next on="COMPLETED" to="copyFile"/>
        <next on="FAILED" to="copyErrorFile"/>
    </step>
    I ended up with something like this:

    Code:
        @Bean
        public Job importCdrsJob() throws Exception {
            return jobBuilders.get("importCdrsJob")
                    .listener(checkJobStatusListener())
                    .start(getFile())
                    .next(extractFile())
                    .next(parseFile())
                        .on("FAILED").to(copyErrorFile())
                        .on("COMPLETED").to(copyFile())
                        .build()
                    .build();
    but I don't see the conditional flow working.

    I tried google, the documentation, samples,... but I'm stuck here for days.

    Please, any clue about how to continue with this?

  • #2
    Solved

    Finally, I figured it out using a debugger.
    Previous statement was adding in the flow the step copyFile after copyErrorFile was completed.
    That and the documentation gave me the clue: I have to use .from().

    Code:
        @Bean
        public Job importCdrsJob() throws Exception {
    
            return jobBuilders.get("importCdrsJob")
                    .listener(checkJobStatusListener())
                    .start(getFile())
                    .next(extractFile())
                    .next(parseFile()).on("FAILED").to(copyErrorFile())
                    .from(parseFile()).on("COMPLETED").to(copyFile()).build()
                    .build();
    
        }
    That was tested and works perfectly.

    Comment

    Working...
    X