Announcement Announcement Module
Collapse
No announcement yet.
SkipLimit Problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • SkipLimit Problem

    Hi,

    This is my job configuration

    <bean id="hibernateJob" parent="simpleJob">
    <!-- set restartable=false so that this job can be used by more than one test -->
    <property name="restartable" value="true" />
    <property name="steps">
    <bean id="step1" parent="skipLimitStep">
    <property name="skipLimit" value="5" />
    <property name="itemReader" ref="hibernateItemReader" />
    <property name="itemWriter" ref="hibernateItemWriter" />
    <property name="commitInterval" value="1" />
    <property name="skippableExceptionClasses" value="java.lang.Exception"/>

    </bean>
    </property>
    </bean>

    I've three records in my table, reading it and inserting into another table.
    When i throw any exception while processing the second record, i thought it will be skipped and continued with the third one but the second record is processed again and again for five times.

    Then it throws skip limit exceeded exception.
    How to handle this?

  • #2
    You can either configure the exception not to cause rollback using setNoRollbackForExceptionClasses or if rollback is desired you need to make sure your item implements equals() so that it can be reliably recognized when encountered after rollback and skipped (last you can take a look at ItemKeyGenerator).

    Comment


    • #3
      Robert,

      Thanks for the reply.
      Im little bit confused here.
      If skip limit and skippableexception classes are not for skipping that step
      then what is the use for those?

      Also can you please guide me how to implement ItemKeyGenerator and equals()?
      It will be helpful for me if you attach some sample configuration or implementations.

      Comment


      • #4
        Error while writing items by default causes rollback of the chunk. When the chunk is re-processed items may be re-created (they are not the same java objects) so unless equals() is overriden the framework can't recognize an item it should skip. Using the apache commons EqualsBuilder for implemeting equals() meets the common needs.

        Comment


        • #5
          Hi,

          As I can see you have configured a step which uses the skipLimitStep as its parent. This is the SkipLimitStepFactoryBean which has got a ItemKeyGenerator injected by default. Now the way it identifies objects that need to be skipped is based on the equals method i.e. the object which is created in the reader and passed to the writer has to have a proper equals implementation based on a unique key....the default mechanism for equals is address reference check which in my opinion is not very safe...so always override it

          hope this helps

          Thanks..Vijay

          Comment


          • #6
            It looks to me like you just haven't put it in a skip limit. By default I think it's either 0 or 1. You need to set some kind of ceiling.

            Comment


            • #7
              All,

              Thanks a lot for the replies.
              Im able to solve this issue to some extent by overriding equals methods.
              I gave skip limit as 1 and it tries the same record for one more time and skips that. Then it continues with the rest.

              Is it possible to avoid trying once again when it encounters any exception?
              I gave skip limit as 0 but its not skipping, the whole process gets stopped.

              Comment


              • #8
                Is it possible to avoid trying once again when it encounters any exception?
                Use the 'noRollbackForExceptionClasses' property of the factory bean

                Comment

                Working...
                X