-
Dec 26th, 2012, 03:26 AM
#1
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!
-
Dec 27th, 2012, 09:31 AM
#2
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.
-
Dec 27th, 2012, 09:37 AM
#3
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 ...
-
Dec 27th, 2012, 09:42 AM
#4
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).
-
Dec 27th, 2012, 09:46 AM
#5
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
-
Dec 27th, 2012, 09:54 AM
#6
Can you post your job configuration?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules