Results 1 to 5 of 5

Thread: How can I rollback a step?

  1. #1
    Join Date
    Jul 2009
    Location
    London, UK
    Posts
    47

    Default How can I rollback a step?

    Hello,

    We currently have the following step defined:
    Code:
    <step id="readWriteWorks">
    			<tasklet>
    				<chunk reader="reader" processor="processor" writer="writer" commit-interval="500">					
    			</tasklet>
    			<end on="COMPLETED"/>
    </step>
    Under this configuration whenever an Exception occurs, while processing a chunk, that chunk(of 500) import will be rollbacked. But what if one wants to rollback the whole step instead of just the chunk.
    What if one million rows have already been imported prior to the failed chunk and we want those rows to be part of the transaction?

    Is there a configuration option for that?

    Thank you,
    Savvas

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

    Default

    you can't rollback a whole step (that's the point of chunk-processing). The only think you can is using a compensating transaction in the next step ("rolling back" the items yourself, because you marked them in the previous step).

  3. #3
    Join Date
    Jul 2009
    Location
    London, UK
    Posts
    47

    Default

    Hi Arno,

    Isn't that a big limitation though? Having to "manually" rollback?
    I'm pretty sure there are many use cases where the requirement is "all or nothing"..

    I am wondering what happens if I don't define a chunk and just implement a step. Would that step be executed in one transaction?

    Thanks,
    Savvas

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

    Default

    Isn't that a big limitation though? Having to "manually" rollback?
    I'm pretty sure there are many use cases where the requirement is "all or nothing"..
    some scenarios are exactly the contrary: a bad item shouldn't compromise all the other items (items in a batch job are supposed to be independent).

    You can set up a very large chunk-size or even set your own completion strategy (chunk-completion-policy attribute) to decide when the commit should happen, but the rollback can take a long time, depending on the number of items (long time can mean hours or even days).

    I am wondering what happens if I don't define a chunk and just implement a step. Would that step be executed in one transaction?
    you can implement a Tasklet for that.

  5. #5
    Join Date
    Jul 2009
    Location
    London, UK
    Posts
    47

    Default

    thanks very much for all the input. The Tasklet approach seems more appropriate for our use case.

    Regards,
    Savvas

Posting Permissions

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