Announcement Announcement Module
Collapse
No announcement yet.
CompositeItemWriter not registering StepExecutionListener Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • CompositeItemWriter not registering StepExecutionListener

    Hi All,

    I may be doing this incorrectly; but it seems CompositeItemWriter does not register the StepExecutionListener correctly if one it's delegate ItemWriter implements the StepExecutionListener interface.

    Here is the Job:

    Code:
    	<batch:job id="testJob">
    		<batch:step id="step1">
    			<batch:tasklet>
    				<batch:chunk commit-interval="2" >
    					<batch:reader>
    						<ref bean="itemReader"/>
    					</batch:reader>
    					<batch:processor>
    						<ref bean="itemProcessor"/>
    					</batch:processor>
    					<batch:writer>
    						<ref bean="compositeWriter"/>
    					</batch:writer>
    					<batch:streams>
    						<batch:stream ref="documentAccumulatorWriter"/>
    					</batch:streams>
    				</batch:chunk>
    			</batch:tasklet>
    		</batch:step>
    		<batch:listeners>
    			<batch:listener ref="documentAccumulatorWriter"/>
    		</batch:listeners>
    	</batch:job>
    Here is the Composite writer definition
    Code:
    	<bean id="compositeWriter" class="org.springframework.batch.item.support.CompositeItemWriter">
    		<property name="delegates">
    			<list>
    				<ref bean="documentAccumulatorWriter"/>
    			</list>
    		</property>
    	</bean>
    Here is the ItemListener Class Definition

    Code:
    public class DocumentAccumelatorItemWriter implements ItemWriter<ClaimPrintBatch>, StepExecutionListener, JobExecutionListener, ItemStream{
    The JobExecutionListener and ItemStream are working, the problem is just with StepExecutionListener.

    At the moment I am just playing around with a prototype; but was really hoping to use the CompositeWriter. Please let me know if it's something I am doing wrong or if there is a way to get around this issue. Thank you.

  • #2
    Nothing wrong here. The composite writer should not register listeners because you might not want them to be registered (also because it is a cyclic dependency in the source). You have to register all listeners and streams explictly if they aren't the "main" reader, writer or processor in a step.

    Comment

    Working...
    X