Results 1 to 7 of 7

Thread: Item Write Listener not getting invoked

  1. #1
    Join Date
    Jun 2008
    Posts
    4

    Default 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 at 01:19 AM.

  2. #2
    Join Date
    Dec 2006
    Posts
    1,061

    Default

    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.

  3. #3
    Join Date
    Dec 2006
    Posts
    1,061

    Default

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

  4. #4
    Join Date
    Apr 2008
    Posts
    28

    Default

    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

  5. #5
    Join Date
    Dec 2006
    Posts
    1,061

    Default

    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)

  6. #6
    Join Date
    Apr 2008
    Location
    Philadelphia, US
    Posts
    198

    Default

    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
    Humans are stateful and mutable beings that have no problems processing many things concurrently and share state with others + they are usually "coupled"

  7. #7
    Join Date
    Apr 2008
    Posts
    28

    Thumbs up

    Thanks Lucas & Litius....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •