Results 1 to 2 of 2

Thread: Chunk Processing: failure and rollback

  1. #1

    Question Chunk Processing: failure and rollback

    Hi,

    I have a simple batch program (reader/writer) with a chunk size of 5.
    My input table has 20 numbers (1,2,3...,20)
    I am copying these number to output table (chunk size of 5).

    My writer is marked as @Transactional(propogation=Propogation.REQUIRES_NE W), so i expect that all the items in the chunk are inserted in same transaction)

    When I come first time in my writer, i will have a list size of 5 => [1,2,3,4,5].

    I insert the first 3 items, then on 4th item, before insert; i throw an exception deliberately. Since no exception is skipped; the job fails.

    But, i notice that 3 items have been inserted to DB; i expected that the chunk of 5 will either all be inserted; or none will be inserted.

    Is there any settings that have to be done to make all the items in a chunk insert in same transaction?

    Regards,
    Pravin

  2. #2
    Join Date
    Sep 2008
    Location
    Chicagoland, IL
    Posts
    351

    Default

    By default, everything should work as you described so without seeing your configuration, it's hard to tell. If you can post your XML, we can look further.
    Michael Minella
    Spring Batch Lead
    Author - Pro Spring Batch
    http://www.michaelminella.com
    Twitter: @MichaelMinella

Tags for this Thread

Posting Permissions

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