Tabnine Logo
SimpleRetryExceptionHandler
Code IndexAdd Tabnine to your IDE (free)

How to use
SimpleRetryExceptionHandler
in
org.springframework.batch.core.step.item

Best Java code snippets using org.springframework.batch.core.step.item.SimpleRetryExceptionHandler (Showing top 14 results out of 315)

origin: spring-projects/spring-batch

SimpleRetryExceptionHandler exceptionHandler = new SimpleRetryExceptionHandler(retryPolicyWrapper,
    getExceptionHandler(), nonRetryableExceptionClasses);
((RepeatTemplate) stepOperations).setExceptionHandler(exceptionHandler);
origin: spring-projects/spring-batch

/**
 * If retry is exhausted set up some state in the context that can be used
 * to signal that the exception should be handled.
 *
 * @see org.springframework.retry.RetryListener#close(org.springframework.retry.RetryContext,
 * org.springframework.retry.RetryCallback, java.lang.Throwable)
 */
@Override
public <T, E extends Throwable> void close(RetryContext context, RetryCallback<T, E> callback, Throwable throwable) {
  if (!retryPolicy.canRetry(context)) {
    if (logger.isDebugEnabled()) {
      logger.debug("Marking retry as exhausted: "+context);
    }
    getRepeatContext().setAttribute(EXHAUSTED, "true");
  }
}
origin: spring-projects/spring-batch

/**
 * @param retryPolicy
 * @param ex
 * @return
 */
private SimpleRetryExceptionHandler getHandlerAfterRetry(RetryPolicy retryPolicy, RuntimeException ex,
    Collection<Class<? extends Throwable>> fatalExceptions) {
  // Always rethrow if the retry is exhausted
  SimpleRetryExceptionHandler handler = new SimpleRetryExceptionHandler(retryPolicy,
      new SimpleLimitExceptionHandler(0), fatalExceptions);
  // Simulate a failed retry...
  RetryContext retryContext = retryPolicy.open(null);
  retryPolicy.registerThrowable(retryContext, ex);
  handler.close(retryContext, null, ex);
  return handler;
}
origin: spring-projects/spring-batch

/**
 * Test method for
 * {@link org.springframework.batch.core.step.item.SimpleRetryExceptionHandler#handleException(org.springframework.batch.repeat.RepeatContext, java.lang.Throwable)} .
 */
public void testNoRethrowWhenRetryNotExhausted() throws Throwable {
  RetryPolicy retryPolicy = new AlwaysRetryPolicy();
  RuntimeException ex = new RuntimeException("foo");
  SimpleRetryExceptionHandler handler = getHandlerAfterRetry(retryPolicy, ex, Collections
      .<Class<? extends Throwable>> singleton(Error.class));
  // Then pretend to handle the exception in the parent context...
  handler.handleException(context.getParent(), ex);
  assertEquals(0, context.attributeNames().length);
  assertEquals(0, context.getParent().attributeNames().length);
}
origin: spring-projects/spring-batch

/**
 * Test method for
 * {@link org.springframework.batch.core.step.item.SimpleRetryExceptionHandler#handleException(org.springframework.batch.repeat.RepeatContext, java.lang.Throwable)} .
 */
public void testRethrowWhenFatal() throws Throwable {
  RetryPolicy retryPolicy = new AlwaysRetryPolicy();
  RuntimeException ex = new RuntimeException("foo");
  SimpleRetryExceptionHandler handler = getHandlerAfterRetry(retryPolicy, ex, Collections
      .<Class<? extends Throwable>> singleton(RuntimeException.class));
  // Then pretend to handle the exception in the parent context...
  try {
    handler.handleException(context.getParent(), ex);
    fail("Expected RuntimeException");
  }
  catch (RuntimeException e) {
    assertEquals(ex, e);
  }
  assertEquals(0, context.attributeNames().length);
  // One for the counter in the delegate exception handler
  assertEquals(1, context.getParent().attributeNames().length);
}
origin: org.springframework.batch/spring-batch-core

SimpleRetryExceptionHandler exceptionHandler = new SimpleRetryExceptionHandler(retryPolicyWrapper,
    getExceptionHandler(), nonRetryableExceptionClasses);
((RepeatTemplate) stepOperations).setExceptionHandler(exceptionHandler);
origin: org.springframework.batch/spring-batch-core

/**
 * If retry is exhausted set up some state in the context that can be used
 * to signal that the exception should be handled.
 *
 * @see org.springframework.retry.RetryListener#close(org.springframework.retry.RetryContext,
 * org.springframework.retry.RetryCallback, java.lang.Throwable)
 */
@Override
public <T, E extends Throwable> void close(RetryContext context, RetryCallback<T, E> callback, Throwable throwable) {
  if (!retryPolicy.canRetry(context)) {
    if (logger.isDebugEnabled()) {
      logger.debug("Marking retry as exhausted: "+context);
    }
    getRepeatContext().setAttribute(EXHAUSTED, "true");
  }
}
origin: spring-projects/spring-batch

/**
 * Test method for
 * {@link org.springframework.batch.core.step.item.SimpleRetryExceptionHandler#handleException(org.springframework.batch.repeat.RepeatContext, java.lang.Throwable)} .
 */
public void testRethrowWhenRetryExhausted() throws Throwable {
  RetryPolicy retryPolicy = new NeverRetryPolicy();
  RuntimeException ex = new RuntimeException("foo");
  SimpleRetryExceptionHandler handler = getHandlerAfterRetry(retryPolicy, ex, Collections
      .<Class<? extends Throwable>> singleton(Error.class));
  // Then pretend to handle the exception in the parent context...
  try {
    handler.handleException(context.getParent(), ex);
    fail("Expected RuntimeException");
  }
  catch (RuntimeException e) {
    assertEquals(ex, e);
  }
  assertEquals(0, context.attributeNames().length);
  // One for the retry exhausted flag and one for the counter in the
  // delegate exception handler
  assertEquals(2, context.getParent().attributeNames().length);
}
origin: org.springframework.batch.core/org.motechproject.org.springframework.batch.core

SimpleRetryExceptionHandler exceptionHandler = new SimpleRetryExceptionHandler(retryPolicyWrapper,
    getExceptionHandler(), nonRetryableExceptionClasses);
((RepeatTemplate) stepOperations).setExceptionHandler(exceptionHandler);
origin: org.springframework.batch/org.springframework.batch.core

/**
 * If retry is exhausted set up some state in the context that can be used
 * to signal that the exception should be handled.
 * 
 * @see org.springframework.batch.retry.RetryListener#close(org.springframework.batch.retry.RetryContext,
 * org.springframework.batch.retry.RetryCallback, java.lang.Throwable)
 */
public <T> void close(RetryContext context, RetryCallback<T> callback, Throwable throwable) {
  if (!retryPolicy.canRetry(context)) {
    logger.debug("Marking retry as exhausted: "+context);
    getRepeatContext().setAttribute(EXHAUSTED, "true");
  }
}
origin: apache/servicemix-bundles

SimpleRetryExceptionHandler exceptionHandler = new SimpleRetryExceptionHandler(retryPolicyWrapper,
    getExceptionHandler(), nonRetryableExceptionClasses);
((RepeatTemplate) stepOperations).setExceptionHandler(exceptionHandler);
origin: org.springframework.batch.core/org.motechproject.org.springframework.batch.core

/**
 * If retry is exhausted set up some state in the context that can be used
 * to signal that the exception should be handled.
 *
 * @see org.springframework.retry.RetryListener#close(org.springframework.retry.RetryContext,
 * org.springframework.retry.RetryCallback, java.lang.Throwable)
 */
@Override
public <T, E extends Throwable> void close(RetryContext context, RetryCallback<T, E> callback, Throwable throwable) {
  if (!retryPolicy.canRetry(context)) {
    logger.debug("Marking retry as exhausted: "+context);
    getRepeatContext().setAttribute(EXHAUSTED, "true");
  }
}
origin: org.springframework.batch/org.springframework.batch.core

SimpleRetryExceptionHandler exceptionHandler = new SimpleRetryExceptionHandler(retryPolicyWrapper,
    getExceptionHandler(), nonRetryableExceptionClasses);
((RepeatTemplate) stepOperations).setExceptionHandler(exceptionHandler);
origin: apache/servicemix-bundles

/**
 * If retry is exhausted set up some state in the context that can be used
 * to signal that the exception should be handled.
 *
 * @see org.springframework.retry.RetryListener#close(org.springframework.retry.RetryContext,
 * org.springframework.retry.RetryCallback, java.lang.Throwable)
 */
@Override
public <T, E extends Throwable> void close(RetryContext context, RetryCallback<T, E> callback, Throwable throwable) {
  if (!retryPolicy.canRetry(context)) {
    if (logger.isDebugEnabled()) {
      logger.debug("Marking retry as exhausted: "+context);
    }
    getRepeatContext().setAttribute(EXHAUSTED, "true");
  }
}
org.springframework.batch.core.step.itemSimpleRetryExceptionHandler

Javadoc

An ExceptionHandler that is aware of the retry context so that it can distinguish between a fatal exception and one that can be retried. Delegates the actual exception handling to another ExceptionHandler.

Most used methods

  • <init>
    Create an exception handler from its mandatory properties.
  • getRepeatContext
    Get the parent context (the retry is in an inner "chunk" loop and we want the exception to be handle
  • close
    If retry is exhausted set up some state in the context that can be used to signal that the exception
  • handleException
    Check if the exception is going to be retried, and veto the handling if it is. If retry is exhausted

Popular in Java

  • Running tasks concurrently on multiple threads
  • notifyDataSetChanged (ArrayAdapter)
  • getSystemService (Context)
  • getExternalFilesDir (Context)
  • BufferedReader (java.io)
    Wraps an existing Reader and buffers the input. Expensive interaction with the underlying reader is
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • PrintStream (java.io)
    Fake signature of an existing Java class.
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • Logger (org.slf4j)
    The org.slf4j.Logger interface is the main user entry point of SLF4J API. It is expected that loggin
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now