Announcement Announcement Module
Collapse
No announcement yet.
Spring Batch 2.2 Java Config Problem(JobExecutionDecider) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Batch 2.2 Java Config Problem(JobExecutionDecider)

    I had started using Spring Batch 2.2 with java configuration(@EnableBatchProcessing).I am new to @JavaConfig and just adapting to builder syntax.
    Below is the XML configuration snippet which i want to convert into Java Config

    Code:
    <job id="importProductsJob" xmlns="http://www.springframework.org/schema/batch">
          <step id="readWrite" next="skippedDecision">
              <tasklet>
                 <chunk reader="reader" writer="writer" commit-interval="100" />
              </tasklet>
           </step>
          <decision id="skippedDecision"  decider="skippedDecider">
                 <next on="SKIPPED" to="generateReport"/>
                 <next on="*" to="clean" />
           </decision>
            <step id="generateReport" next="sendReport">
                    <tasklet ref="generateReportTasklet" />
           </step>
            <step id="sendReport" next="clean">
                   <tasklet ref="sendReportTasklet" />
           </step>
           <step id="clean">
              <tasklet ref="cleanTasklet" />
          </step>
    </job>
    I am stuck in implementing "skippedDecision" state and how "*" would be implemented.
    Below is the code I am able to change:

    Code:
    jobBuilderFactory.get(importProductsJob)
                   .start(readWriteStep).on("COMPLETED")                   //once read write is done
                         .to(skippedDecider())                                      //skipped will see if outcome is "skipped"
                                .on("SKIPPED").to(generateReport()).to(sendReport()) // complete this flow
                                         .on("*").to(clean()).end().build();                   // if outcome is anything else, then just execute clean
    This code is not working and I am confused in JobBuilders.
    Please anyone can provide me java config for building up two way decision using JobExecutionDecider flow.

  • #2
    I was not using a JobExecutionDecider but my problem was similar to yours.
    Check this and let us know if it gives you an idea to solve it:

    http://forum.springsource.org/showth...ditional-flows

    Comment


    • #3
      Guys it was very easy you just need form(decider())

      Below is the code:
      jobBuilderFactory.get(importProductsJob)
      .start(readWriteStep).
      .next(skippedDecider())
      .on("SKIPPED").to(generateReport()).to(sendReport( ))
      from(skippedDecider()).on("*").to(clean()).end().b uild();

      I've got it from spring batch source(github).Its full of test cases and rich in example.One the best test coverage i have seen.

      Comment


      • #4
        thanks Elhodred for a quick reply.

        Comment

        Working...
        X