Class SkipLimitStepFactoryBean

  extended by org.springframework.batch.core.step.item.AbstractStepFactoryBean
      extended by org.springframework.batch.core.step.item.SimpleStepFactoryBean
          extended by org.springframework.batch.core.step.item.SkipLimitStepFactoryBean
All Implemented Interfaces:
BeanNameAware, FactoryBean
Direct Known Subclasses:

public class SkipLimitStepFactoryBean
extends SimpleStepFactoryBean

Factory bean for step that provides options for configuring skip behavior. User can set setSkipLimit(int) to set how many exceptions of setSkippableExceptionClasses(Class[]) types are tolerated. setFatalExceptionClasses(Class[]) will cause immediate termination of job - they are treated as higher priority than setSkippableExceptionClasses(Class[]), so the two lists don't need to be exclusive. Skippable exceptions on write will by default cause transaction rollback - to avoid rollback for specific exception class include it in the transaction attribute as "no rollback for".

Dave Syer, Robert Kasanicky
See Also:

Field Summary
Fields inherited from class org.springframework.batch.core.step.item.SimpleStepFactoryBean
Constructor Summary
Method Summary
 void addFatalExceptionIfMissing(Class cls)
protected  void applyConfiguration(ItemOrientedStep step)
          Uses the setSkipLimit(int) value to configure item handler and and exception handler.
 void setBackOffPolicy(BackOffPolicy backOffPolicy)
          Public setter for the BackOffPolicy.
 void setCacheCapacity(int cacheCapacity)
          Public setter for the capacity of the cache in the retry policy.
 void setFatalExceptionClasses(Class[] fatalExceptionClasses)
          Public setter for exception classes that should cause immediate failure.
 void setItemKeyGenerator(ItemKeyGenerator itemKeyGenerator)
          Public setter for the ItemKeyGenerator.
 void setRetryableExceptionClasses(Class[] retryableExceptionClasses)
          Public setter for the Class[].
 void setRetryLimit(int retryLimit)
          Public setter for the retry limit.
 void setRetryListeners(RetryListener[] retryListeners)
          Public setter for the RetryListeners.
 void setRetryPolicy(RetryPolicy retryPolicy)
          Setter for the retry policy.
 void setSkipLimit(int skipLimit)
          Public setter for a limit that determines skip policy.
 void setSkippableExceptionClasses(Class[] exceptionClasses)
          Public setter for exception classes that when raised won't crash the job but will result in transaction rollback and the item which handling caused the exception will be skipped.
Methods inherited from class org.springframework.batch.core.step.item.SimpleStepFactoryBean
getChunkOperations, getExceptionHandler, getItemHandler, getStepOperations, setChunkCompletionPolicy, setCommitInterval, setExceptionHandler, setItemHandler, setTaskExecutor, setThrottleLimit
Methods inherited from class org.springframework.batch.core.step.item.AbstractStepFactoryBean
getItemReader, getItemWriter, getListeners, getName, getObject, getObjectType, getTransactionAttribute, isSingleton, setAllowStartIfComplete, setBeanName, setItemReader, setItemWriter, setJobRepository, setListeners, setSingleton, setStartLimit, setStreams, setTransactionAttribute, setTransactionManager
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public SkipLimitStepFactoryBean()
Method Detail


public void setRetryPolicy(RetryPolicy retryPolicy)
Setter for the retry policy. If this is specified the other retry properties are ignored (retryLimit, backOffPolicy, retryableExceptionClasses).

retryPolicy - a stateless RetryPolicy


public void setRetryLimit(int retryLimit)
Public setter for the retry limit. Each item can be retried up to this limit. Note the limit includes the initial attempt, so it must be greater or equal to 1.

retryLimit - the retry limit to set


public void setCacheCapacity(int cacheCapacity)
Public setter for the capacity of the cache in the retry policy. If more items than this fail without being skipped or recovered an exception will be thrown. This is to guard against inadvertent infinite loops generated by item identity problems. If a large number of items are failing and not being recognized as skipped, it usually signals a problem with the key generation (often equals and hashCode in the item itself). So it is better to enforce a strict limit than have weird looking errors, where a skip limit is reached without anything being skipped.
The default value should be high enough and more for most purposes. To breach the limit in a single-threaded step typically you have to have this many failures in a single transaction. Defaults to the value in the MapRetryContextCache.

cacheCapacity - the cacheCapacity to set


public void setRetryableExceptionClasses(Class[] retryableExceptionClasses)
Public setter for the Class[].

retryableExceptionClasses - the retryableExceptionClasses to set


public void setBackOffPolicy(BackOffPolicy backOffPolicy)
Public setter for the BackOffPolicy.

backOffPolicy - the BackOffPolicy to set


public void setRetryListeners(RetryListener[] retryListeners)
Public setter for the RetryListeners.

retryListeners - the RetryListeners to set


public void setSkipLimit(int skipLimit)
Public setter for a limit that determines skip policy. If this value is positive then an exception in chunk processing will cause the item to be skipped and no exception propagated until the limit is reached. If it is zero then all exceptions will be propagated from the chunk and cause the step to abort. Note that if chunks are executed concurrently the number of skips can potentially exceed the skip limit and step can still finish successfully. This is due to the fact that overall skip count is not being synchronized between concurrent chunks while they processing, only on chunk boundaries.

skipLimit - the value to set. Default is 0 (never skip).


public void setSkippableExceptionClasses(Class[] exceptionClasses)
Public setter for exception classes that when raised won't crash the job but will result in transaction rollback and the item which handling caused the exception will be skipped.

exceptionClasses - defaults to Exception


public void setFatalExceptionClasses(Class[] fatalExceptionClasses)
Public setter for exception classes that should cause immediate failure.

fatalExceptionClasses - Error by default


public void setItemKeyGenerator(ItemKeyGenerator itemKeyGenerator)
Public setter for the ItemKeyGenerator. This is used to identify failed items so they can be skipped if encountered again, generally in another transaction.

itemKeyGenerator - the ItemKeyGenerator to set.


protected void applyConfiguration(ItemOrientedStep step)
Uses the setSkipLimit(int) value to configure item handler and and exception handler.

applyConfiguration in class SimpleStepFactoryBean


public void addFatalExceptionIfMissing(Class cls)

Copyright © 2009 SpringSource. All Rights Reserved.