Announcement Announcement Module
Collapse
No announcement yet.
Item Write Listener not getting invoked Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Item Write Listener not getting invoked

    Hi,

    here is my configuration for the job. I have configured an ItemWriteListener "fileOutputItemWriteListener" and an ItemReadListener "fileOutputItemReadListener" . WHile the read listener gets invoked, the write listener does not . Any ideas????
    Code:
    <bean id="fileOutputJob" parent="simpleJob">
    		<property name="name" value="fileOutputJob" />
    		<property name="steps">
    			<list>
    				<bean parent="skipLimitStep">
    					<property name="exceptionHandler" ref="exceptionHandler"/>
    					<property name="commitInterval" value="10" />
    					<property name="skipLimit" value="1000"/>
    					<property name="itemReader" ref="flatFileItemReader" />
    					<property name="itemWriter" ref="flatFileItemWriter"/>
    					<list>
    						<ref bean="fileOutputItemReaderListener" />
    						<ref bean="fileOutputItemWriteListener" />
    						
    					</list>
    												</bean>
    			</list>
    		</property>
    	</bean>
    Am i missing any configuration ?

    TIA
    Last edited by batchuser; Jun 16th, 2008, 01:19 AM.

  • #2
    Usually it's because you have some kind of delegate in your writer and need to register it separately. You can do this via the 'listeners' property on the step factory beans.

    Comment


    • #3
      Actually, looking at your configuration, I'm not sure how it even works, since the list isn't part of any property.

      Comment


      • #4
        If we need to configure more than one listeners, how can we configure those in our context file?

        <property name="listeners" ref="stepExecutionStatusListener,batchStatusLogger Listener" />

        Please direct me

        Comment


        • #5
          It's a list, so it uses the standard Spring List tag. You should be able to find more information on it in the Spring Reference documentation, or there's plenty of examples in the samples as well (lists of steps, etc)

          Comment


          • #6
            Shahul,

            Here is an example on how to define multiple listeners:

            Code:
            	<bean id="simpleStep" class="org.springframework.batch.core.step.item.SkipLimitStepFactoryBean">
            		
            		<property name="skipLimit" value="100" />
            		<property name="commitInterval" value="30" />
            		
            		<property name="transactionManager" ref="batchTransactionManager" />
            		<property name="listeners" ref="stepListeners" />
            		<property name="skippableExceptionClasses" ref="nonFatalExceptions" />
            		<property name="jobRepository" ref="simpleJobRepository" />
            
            	</bean>
            
            	<util:list id="stepListeners">
            		<ref bean="oneStepListener"/>
            		<ref bean="twoStepListener"/>		
            		<ref bean="threeStepListener"/>		
            	</util:list>
            ----------------------------------------------------
            batchuser,

            Can you post your code for "fileOutputItemWriteListener" that does not get called. I suspect that it does not get invoked either because there is some kind of delegation in your ItemWriter (in which case you should delegate calls to afterStep, beforeStep, onErrorInStep as well) or you not implementing "ItemWriteListener" interface to use these:

            beforeWrite
            afterWrite
            onWriteError

            ----------------------------------------------------

            litius

            Comment


            • #7
              Thanks Lucas & Litius....

              Comment

              Working...
              X