Announcement Announcement Module
Collapse
No announcement yet.
SkipListenerSupport.onSkipInWrite() Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • SkipListenerSupport.onSkipInWrite()

    Hi,


    We have a job with the following skip step

    Code:
    <bean id="stepId" parent="skipLimitStep">
    <property name="itemReader">
                <ref local="stagingItemReader"/>
            </property>
            <property name="itemWriter">
                <ref local="bsWriter"/>
            </property>
            <property name="listeners" ref ="recordErrorDataAction"/>
    <property name="skippableExceptionClasses">
                <list value-type="java.lang.Class" >
                    <value>java.lang.Exception</value>
    <value>com.xxx.BSException</value>
                </list>
            </property>
    </bean>
    
    <bean id="recordErrorDataAction"
            class="com.xxx.writer.RecordErrorDataAction">
                    <property name="bSvc" ref="BService"/>
                    <property name="daoRegistry" ref="daoRegistry"/>
        </bean>
    
        <bean id="bsWriter" class="com.xx.writer.BSWriter">
            <property name="someSvc" ref="SomeService"/>
            <property name="daoRegistry" ref="daoRegistry"/>
            <property name="OtherSvc" ref="OtherService"/>
        </bean>
    
    public class RecordErrorDataAction extends SkipListenerSupport {
    
    @Override
        public void onSkipInWrite(Object item, Throwable t) {
            System.out.println(" $$ Skip listener called." + item);
            System.out.println(" $$ Skip listener called." + t);
            doSomeWork(item, t);
        }
    }
    We see the following when batch is run -

    $$ Skip listener called.62
    $$ Skip listener called.com.xx.BSException
    ....
    $$ Skip listener called.62
    $$ Skip listener called.com.xx.BSException
    $$ Skip listener called.147
    $$ Skip listener called.com.xx.BSException
    ...
    $$ Skip listener called.62
    $$ Skip listener called.com.xx.BSException
    $$ Skip listener called.147
    $$ Skip listener called.com.xx.BSException
    $$ Skip listener called.148
    $$ Skip listener called.com.xx.BSException

    onSkipInWrite() gets called for the failed record and for all the previously failed records as well?

    Isn't it supposed to be called only once for the item which is being processed in the current iteration?


    What we want is to write to an error table when that step skips (fails to process).

    Thanks,
    Vineet Bhatia

  • #2
    Just my 2 cents, see whether you can leverage ItemListenerSupport, this may help you to write to an error file or error table:

    http://static.springframework.org/sp...x.html#d0e4049

    Comment


    • #3
      It doesn't really make sense to call onSkipInWrite(..) multiple times for the same item - here you can track the issue:

      http://jira.springframework.org/browse/BATCH-625

      Comment

      Working...
      X