Hi,
I am reading data from CSV flat file using FlatFileItemReader and want to validate the input records and if any errors, I just want to log it and still continue with the other records in the file. Having said that, what would be the good pattern to include the validation layer.
1) Include validation (custom) layer in InputFeedFieldSetMapper while reading the input from flat file and log the invalid records
2) Include validation in Processing layer as shown below and use Errors.rejectValue etc. to log it in log file but I don't want to reject and just want to log it (no idea how to do it and more over if I use CompositeItemProcessor pattern, the subsequent processors won't be called if any Errors out of ValidatingItemProcessor)Code:<bean name="feedMapper" class="com.abc.batch.core.reader.mapper.InputFeedFieldSetMapper"/> <bean name="feedLineMapper" class="org.springframework.batch.item.file.mapping.DefaultLineMapper"> <property name="fieldSetMapper" ref="feedMapper" /> <property name="lineTokenizer" ref="feedLineTokenizer" /> </bean>
Please help me with this. Thanks.Code:<bean id="feedValidator" class="com.abc.batch.core.reader.validator.impl.FileLoadValidator" /> <bean id="validator" class="org.springframework.batch.item.validator.SpringValidator"> <property name="validator" ref="feedValidator" /> </bean> <bean id="validateFileLoadProcessor" class="org.springframework.batch.item.validator.ValidatingItemProcessor"> <property name="validator" ref="validator" /> </bean>


Reply With Quote