Spring Batch - how many records are read & amp; treaty


Is it possible to tell how many records are read and/or processed once the job is executed completely? I've a job that reads data from the database and in the processor, I filter few records based on certain criteria and send them to the writer. I would like to know how many total records are read from the DB and how many are sent to the writer step.

Here is my batch config file.

<bean id="dbItemReader" class="....JdbcCursorItemReader">
    <property name="datasource" ref="datasource"/>
    <property name="sql" ref="select * from"/>
    <property name="rowMapper">
      <bean class="com.my.MyRowMapper"/>

<bean id="itemProcessor" class="com.my.MyItemProcessor"/>
<bean id="itemWriter" class="com.my.MyItemWriter"/>

<batch:job id="myJob">
    <batch:step id="step1">
       <batch:tasklet transaction-manager="jobTransactionManager">
             <batch:chunk reader="dbItemReader" processor="itemProcessor" writer="itemWriter" commit-interval="100"/>

Spring Batch stores the number of items read, processed, skipped, written, etc in the job repository. Assuming you're using a database job repository, you can view them there in the BATCH_STEP_EXECUTION table.

You can read more about the information stored in the job repository in the documentation here: http://docs.spring.io/spring-batch/reference/html/metaDataSchema.html