Package org.springframework.batch.core.step.item

# Class BatchRetryTemplate

java.lang.Object
org.springframework.batch.core.step.item.BatchRetryTemplate

All Implemented Interfaces:
  `org.springframework.retry.RetryOperations`

public class BatchRetryTemplate extends Object implements org.springframework.retry.RetryOperations
A special purpose retry template that deals specifically with multi-valued stateful retry. This is useful in the case where the operation to be retried operates on multiple items, and when it fails there is no way to decide which (if any) of the items was responsible. The `RetryState` used in the execute methods is composite, and when a failure occurs, all of the keys in the composite are "tarred with the same brush". Subsequent attempts to execute with any of the keys that have failed previously results in a new attempt and the previous state is used to check the `RetryPolicy`. If one of the failed items eventually succeeds then the others in the current composite for that attempt will be cleared from the context cache (as normal), but there may still be entries in the cache for the original failed items. This might mean that an item that did not cause a failure is never retried because other items in the same batch fail fatally first.

Author:
  Dave Syer

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `BatchRetryTemplate()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `canRetry(org.springframework.retry.RetryContext context)`
  `static List<org.springframework.retry.RetryState>`
  `createState(List<?> keys)`
  `static List<org.springframework.retry.RetryState>`
  `createState(List<?> keys, org.springframework.classify.Classifier<? super Throwable,Boolean> classifier)`
  `final <T, E extends Throwable>
  T`
  `execute(org.springframework.retry.RetryCallback<T,E> retryCallback)`
  `<T, E extends Throwable>
  T`
  `execute(org.springframework.retry.RetryCallback<T,E> retryCallback, Collection<org.springframework.retry.RetryState> states)`
  `final <T, E extends Throwable>
  T`
  `execute(org.springframework.retry.RetryCallback<T,E> retryCallback, org.springframework.retry.RecoveryCallback<T> recoveryCallback)`
  `<T, E extends Throwable>
  T`
  `execute(org.springframework.retry.RetryCallback<T,E> retryCallback, org.springframework.retry.RecoveryCallback<T> recoveryCallback, Collection<org.springframework.retry.RetryState> states)`
  `final <T, E extends Throwable>
  T`
  `execute(org.springframework.retry.RetryCallback<T,E> retryCallback, org.springframework.retry.RecoveryCallback<T> recoveryCallback, org.springframework.retry.RetryState retryState)`
  `final <T, E extends Throwable>
  T`
  `execute(org.springframework.retry.RetryCallback<T,E> retryCallback, org.springframework.retry.RetryState retryState)`
  `void`
  `registerListener(org.springframework.retry.RetryListener listener)`
  `void`
  `setBackOffPolicy(org.springframework.retry.backoff.BackOffPolicy backOffPolicy)`
  `void`
  `setListeners(org.springframework.retry.RetryListener[] listeners)`
  `void`
  `setRetryContextCache(org.springframework.retry.policy.RetryContextCache retryContextCache)`
  `void`
  `setRetryPolicy(org.springframework.retry.RetryPolicy retryPolicy)`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### BatchRetryTemplate

    public BatchRetryTemplate()

- ## Method Details

  - ### execute

    public <T, E extends Throwable> T execute(org.springframework.retry.RetryCallback<T,E> retryCallback, Collection<org.springframework.retry.RetryState> states) throws E, Exception
    Throws:
      `E extends Throwable`
      `Exception`

  - ### execute

    public <T, E extends Throwable> T execute(org.springframework.retry.RetryCallback<T,E> retryCallback, org.springframework.retry.RecoveryCallback<T> recoveryCallback, Collection<org.springframework.retry.RetryState> states) throws E, Exception
    Throws:
      `E extends Throwable`
      `Exception`

  - ### execute

    public final <T, E extends Throwable> T execute(org.springframework.retry.RetryCallback<T,E> retryCallback, org.springframework.retry.RecoveryCallback<T> recoveryCallback, org.springframework.retry.RetryState retryState) throws E
    Specified by:
      `execute` in interface `org.springframework.retry.RetryOperations`
    Throws:
      `E extends Throwable`

  - ### execute

    public final <T, E extends Throwable> T execute(org.springframework.retry.RetryCallback<T,E> retryCallback, org.springframework.retry.RecoveryCallback<T> recoveryCallback) throws E
    Specified by:
      `execute` in interface `org.springframework.retry.RetryOperations`
    Throws:
      `E extends Throwable`

  - ### execute

    public final <T, E extends Throwable> T execute(org.springframework.retry.RetryCallback<T,E> retryCallback, org.springframework.retry.RetryState retryState) throws E, org.springframework.retry.ExhaustedRetryException
    Specified by:
      `execute` in interface `org.springframework.retry.RetryOperations`
    Throws:
      `E extends Throwable`
      `org.springframework.retry.ExhaustedRetryException`

  - ### execute

    public final <T, E extends Throwable> T execute(org.springframework.retry.RetryCallback<T,E> retryCallback) throws E
    Specified by:
      `execute` in interface `org.springframework.retry.RetryOperations`
    Throws:
      `E extends Throwable`

  - ### createState

    public static List<org.springframework.retry.RetryState> createState(List<?> keys)

  - ### createState

    public static List<org.springframework.retry.RetryState> createState(List<?> keys, org.springframework.classify.Classifier<? super Throwable,Boolean> classifier)

  - ### registerListener

    public void registerListener(org.springframework.retry.RetryListener listener)

  - ### setBackOffPolicy

    public void setBackOffPolicy(org.springframework.retry.backoff.BackOffPolicy backOffPolicy)

  - ### setListeners

    public void setListeners(org.springframework.retry.RetryListener[] listeners)

  - ### setRetryContextCache

    public void setRetryContextCache(org.springframework.retry.policy.RetryContextCache retryContextCache)

  - ### setRetryPolicy

    public void setRetryPolicy(org.springframework.retry.RetryPolicy retryPolicy)

  - ### canRetry

    public boolean canRetry(org.springframework.retry.RetryContext context)