Results 1 to 9 of 9

Thread: RepeatTemplate

  1. #1

    Default 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. #2

    Default

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

  3. #3

    Default

    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.

  4. #4
    Join Date
    Dec 2005
    Location
    Lyon, France
    Posts
    311

    Default

    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.

  5. #5

    Default

    Quote 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?

  6. #6

    Default

    Quote 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).

  7. #7
    Join Date
    Jun 2005
    Posts
    4,232

    Default

    Quote 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?

  8. #8

    Default

    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?

  9. #9
    Join Date
    Dec 2005
    Location
    Lyon, France
    Posts
    311

    Default

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •