How can I get the number of line and the filename in itemProcessor - spring batch -
i using spring batch parse files. in itemprocessor validate if incoming fields correct. if not want throw validationexception , log file corresponding row has wrong fields. so, how can find number of line , filename in itemprocessor?
without seeing itemreader config can't sure if using flatfileitemreader parse csv, if in strict mode validate number of columns.
assuming reader looks this, is:
<bean id="iitemreader" class="org.springframework.batch.item.file.flatfileitemreader" scope="step"> <property name="linestoskip" value="1"/> <property name="comments" value="#" /> <property name="encoding" value="utf-8"/> <property name="linemapper" > <bean class="org.springframework.batch.item.file.mapping.defaultlinemapper"> <property name="linetokenizer"> <bean class="org.springframework.batch.item.file.transform.delimitedlinetokenizer"> <property name="delimiter" value=","/> <property name="names"> <list > <value>first_field</value> <value>second_field</value> </list> </property> <property name="strict" value="true"/> </bean> </property> <property name="fieldsetmapper"> <bean class="uk.co.package.fieldsetmapper"> <property name="dateformat" value="yyyy-mm-dd hh:mm:ss"/> </bean> </property> </bean> </property> </bean>
it throw flatfileparseexception lines can't processed. includes line number , can handled in listener.
spring batch-processing
No comments:
Post a Comment