Apr 17th, 2010, 10:38 AM
Does Spring batch support multiple writers base on custom condition?
I'm moving from my own in-house batch framework. Actually it works perfectly
for me and my clients. I'm moving to Grails and Grails is based on Spring framework.
The problem is I'd like to refactoring all existing libraries to be
Spring-able and I'm deciding to replace in-house batch framework with
spring batch. By the way, I'd like to make sure that it supports most of
the features that my in-house framework has before throwing my
in-house framework away.
1. The first feature that I need the most is "Multiple writers base on condition"
for example if my reader found item error, it should be redirect those items to
ErrorWriter and add the error message column next to the last field. and for
all the rest good items, redirect it to SuccessWriter.
2. Can I do something after batch processing was completed such as generating
batch id, saving that id to database or deleting/moving the original file.
3. I see the chunk processing technique and commit interval but if I'd like to commit
if all items in batch file have no error or rollback all items if at least
one item in batch file are error.
Apr 17th, 2010, 10:45 AM
4. Does spring batch supports "Selecting reader base on custom logic"
I'd like the job to select reader base on file extension.
if the job
found xml file it will use Xml reader
found flat file it will use flat file reader
and so on..
Apr 20th, 2010, 03:36 AM
No one answer me
By the way, google and sourcecodes help me a lot.
And these are the answer that I discovered in last few days
ItemProcessListener can do this. but it seems like I can't append error message to the last
column if I would like to use existing ItemWriter interface. I'll work around for this later.
It's not proven yet, but JobExecutionListener should be the correct answer.
I've not looked at it yet. skip for now.
It is very easy to implemented. I just implements ItemReader interface, set delegated objects,
and examining resource file. just that!