Results 1 to 10 of 11

Thread: Dynamic commit-interval

Hybrid View

  1. #1

    Default Dynamic commit-interval

    Hi all,

    I have a spring batch applications with flat file as item reader.

    This flat contains two differents types of records.

    In the definition of my chunk i have to specify a dynamic commit interval.

    The application has to commit each time it reads a new type of record.

    Exemple :

    1, 'recordType1', 50
    1, 'recordType1', 51
    1, 'recordType1', 52
    COMMIT
    2, 'recordType2', 'foo'
    COMMIT
    1, 'recordType1', 53
    COMMIT
    2, 'recordType2', 'foo'
    COMMIT
    1, 'recordType1', 50
    1, 'recordType1', 50
    1, 'recordType1', 50
    1, 'recordType1', 50
    COMMIT
    2, 'recordType2', 'foo'
    2, 'recordType2', 'foo'
    2, 'recordType2', 'foo'
    2, 'recordType2', 'foo'
    COMMIT


    How can I do this ?

    Thanxs!

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

    Default

    Take a look at the chunk-completion-policy. You can implement the CompletionPolicy interface and configure that to perform some form of logic to determine if the chunk is complete or not.
    Michael Minella
    Spring Batch Lead
    Author - Pro Spring Batch
    http://www.michaelminella.com
    Twitter: @MichaelMinella

  3. #3

    Default

    hi,

    thank you for replying, yes im always searching for it.

    Indeed, it works well with chunk-completion-policy... With a little business logic i can commit by bloc of same records, but i have a problem by using it...

    chunk-completion-policy supposes that the entire resource file is correct because it reads all the resource file before doing anything else.

    If the the resource file has for example three corrects blocs but the fourth is wrong then none records will be inserted in my DB.
    Or i want that the three first corrects blocs will be persisted ...

  4. #4
    Join Date
    Sep 2008
    Location
    Chicagoland, IL
    Posts
    338

    Default

    If you don't want the transaction to roll back, you can skip the exception via the skippable-exception-classes (section 5.1.5 here: http://static.springsource.org/sprin...igureStep.html).
    Michael Minella
    Spring Batch Lead
    Author - Pro Spring Batch
    http://www.michaelminella.com
    Twitter: @MichaelMinella

  5. #5

    Default

    Yes, I know, but I want transaction rollback on the entire bloc that got wrong record, then stopping application

    The previous right blocs must be fully commited

  6. #6
    Join Date
    Sep 2008
    Location
    Chicagoland, IL
    Posts
    338

    Default

    Can you post your job configuration?
    Michael Minella
    Spring Batch Lead
    Author - Pro Spring Batch
    http://www.michaelminella.com
    Twitter: @MichaelMinella

Posting Permissions

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