Announcement Announcement Module
Collapse
No announcement yet.
RepeatTemplate Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • RepeatTemplate

    Hi All,
    My job.xml contain a step with reader, processor and Writer. If any business exception occurs, then current chunk should rollback and pick the next chunk to process.

    Can I use RepeatTemplate?

    If the answer is yes, then how to configure the RepeatTemplate for my case?

    <code>

    <job id="Batch_ControllerJob" restartable="true"
    xmlns="http://www.springframework.org/schema/batch">

    <step id="pricesLoadStep">
    <tasklet transaction-manager="transactionManager">

    <chunk reader="pricesLoadItemReader" processor="pricesLoadItemProcessor"
    writer="pricesLoadItemWriter" commit-interval="2">
    </chunk>

    <no-rollback-exception-classes>
    <include class="batch.core.exception.PricesLoadNoRollbackEx ception" />
    </no-rollback-exception-classes>

    </tasklet>

    </step>

    </job>

    </code>

  • #2
    In think, in your case skippable-exception-classes best match your goal. See Configuring Skip Logic.

    Comment


    • #3
      Thanks for your reply.

      skippable-exception-classes will rollback the current transaction?

      In the processor I am throwing the business exception, if that exception is configured in the skippable-exception-classes it will rollback?

      In my case, according to the business exception either I need to rollback the current transaction or without rollback I need to continue with the next chunk.

      Comment


      • #4
        there's no rollback if a skippable exception is thrown from the reader. There's a rollback if a skippable exception is thrown from the processor or writer. This is the default behavior.

        Comment


        • #5
          Originally posted by arno View Post
          there's no rollback if a skippable exception is thrown from the reader. There's a rollback if a skippable exception is thrown from the processor or writer. This is the default behavior.
          Thanks for your reply arno.

          Can I configure ,
          1. All rollback business exceptions in the skippable-exception-classes ?

          2. All Non rollback business exceptions in the no-rollback-exception-classes?

          Comment


          • #6
            Originally posted by arun4 View Post
            Thanks for your reply arno.

            Can I configure ,
            1. All rollback business exceptions in the skippable-exception-classes ?
            2. All Non rollback business exceptions in the no-rollback-exception-classes?
            Perhaps the following will give you a hint:

            A skippable exception should be also listed as no-rollback exception (otherwise it does not make sense).

            Comment


            • #7
              Originally posted by dma_k View Post
              A skippable exception should be also listed as no-rollback exception (otherwise it does not make sense).
              Actually, I would say that is not the normal best practice (and it isn't the default behaviour). By default I would expect that if there is an exception you want to rollback, and that's what the framework assumes too. The skip listener will be called in the next transaction (if it is successful) - maybe that's what confuses people?

              Comment


              • #8
                Hi Dave,

                Really glad to see your reply. Thanks.

                Analayzing the issue in two perspectives:

                1) Generating a business exception + roll back (according to business)
                2) Generating a business exception + (no roll back)

                In both of these scenarios, the batch should continue with the next chunk.

                How will spring see these business exceptions and roll backing issues?

                what are the configurations to be done to execute the above stated business?

                Can u also highlight, if there are any sample jobs (with roll back + non roll back + next chunk processing) present?

                Comment


                • #9
                  I guess you need to mark both kinds of business exceptions skippable and mark only one with no-rollback (using the appropriate XML tags, see reference documentation).

                  If you really want to be sure about the behavior, you can also write an integration test with mock or stub reader/processor/writer and check the metadata for the number of rollbacks.

                  Comment

                  Working...
                  X