Ganesh Karamala
Ganesh Karamala

Reputation: 513

How to get write count of composite item writer?

How to know write count of each item writer of composite item writer? Here is my composite item writer

<bean id="Writer" class="org.springframework.batch.item.support.ClassifierCompositeItemWriter" scope="step">
<property name="classifier">
    <bean class="org.springframework.batch.classify.BackToBackPatternClassifier">
     <property name="routerDelegate"><bean class="com.classifier.RecordKeeperClassifier" scope="prototype" />
     </property>
    <property name="matcherMap">
        <map>
          <entry key="abc" value-ref="ItemWriter1" />
          <entry key="xyz" value-ref="ItemWriter2" />
          <entry key="*" value-ref="errorItemWriter" />
        </map>
    </property>
    </bean>
</property>
</bean>

How to know no records with "abc" field as a key in the input file . I used footercallback listener and stepExecution.getWriteCount() method to know the writeCount , it is giving total count of inputs records I need only input records count with "abc" field

Upvotes: 0

Views: 2297

Answers (1)

Luca Basso Ricci
Luca Basso Ricci

Reputation: 18413

The total count of written items is cumulative so you have to count item manually using a ItemWriteListener if you are using a built-in writer or - optionally - overriding ItemWriter.write() for a custom writer

Upvotes: 1

Related Questions