Package org.springframework.retry.support

Examples of org.springframework.retry.support.DefaultRetryState


    if (args.length == 1) {
      arg = args[0];
    }
    final Object item = arg;

    RetryState retryState = new DefaultRetryState(
        keyGenerator != null ? keyGenerator.getKey(args) : item,
        newMethodArgumentsIdentifier != null && newMethodArgumentsIdentifier.isNew(args)
    );

    Object result = retryOperations.execute(new MethodInvocationRetryCallback(invocation),
View Full Code Here


  @Test
  public void testExternalRetryWithFailAndNoRetry() throws Throwable {
    MockRetryCallback callback = new MockRetryCallback();

    RetryState retryState = new DefaultRetryState("foo");

    RetryTemplate retryTemplate = new RetryTemplate();
    MapRetryContextCache cache = new MapRetryContextCache();
    retryTemplate.setRetryContextCache(cache);
    retryTemplate.setRetryPolicy(new SimpleRetryPolicy(1, Collections
View Full Code Here

  @Test
  public void testExternalRetryWithSuccessOnRetry() throws Throwable {
    MockRetryCallback callback = new MockRetryCallback();

    RetryState retryState = new DefaultRetryState("foo");

    RetryTemplate retryTemplate = new RetryTemplate();
    MapRetryContextCache cache = new MapRetryContextCache();
    retryTemplate.setRetryContextCache(cache);
    retryTemplate.setRetryPolicy(new SimpleRetryPolicy(2, Collections
View Full Code Here

    policy.setInitialInterval(100);
    policy.setMultiplier(1.5);
    RetryTemplate template = new RetryTemplate();
    template.setBackOffPolicy(policy);
    final List<Long> times = new ArrayList<Long>();
    RetryState retryState = new DefaultRetryState("bar");
    for (int i = 0; i < 3; i++) {
      try {
        template.execute(new RetryCallback<String, Exception>() {
          public String doWithRetry(RetryContext context) throws Exception {
            times.add(System.currentTimeMillis());
View Full Code Here

      }
    };

    Object result = null;
    try {
      retryTemplate.execute(callback, recoveryCallback, new DefaultRetryState("foo"));
      fail("Expected IllegalArgumentException");
    }
    catch (IllegalArgumentException e) {
      // If stateful we have to always rethrow. Clients who want special
      // cases have to implement them in the callback
    }
    result = retryTemplate.execute(callback, recoveryCallback, new DefaultRetryState("foo"));
    // Callback is called once: the recovery path should also be called
    assertEquals(1, callback.attempts);
    assertEquals("bar", result);
  }
View Full Code Here

          }
        }

      };

      O output = batchRetryTemplate.execute(retryCallback, recoveryCallback, new DefaultRetryState(
          getInputKey(item), rollbackClassifier));
      if (output != null) {
        outputs.add(output);
      }
View Full Code Here

      if (logger.isDebugEnabled()) {
        logger.debug("Attempting to write: " + inputs);
      }
      try {
        batchRetryTemplate.execute(retryCallback, recoveryCallback, new DefaultRetryState(inputs,
            rollbackClassifier));
      }
      catch (Exception e) {
        RetryContext context = contextHolder.get();
        if (!batchRetryTemplate.canRetry(context)) {
View Full Code Here

  }

  public static List<RetryState> createState(List<?> keys) {
    List<RetryState> states = new ArrayList<RetryState>();
    for (Object key : keys) {
      states.add(new DefaultRetryState(key));
    }
    return states;
  }
View Full Code Here

  }

  public static List<RetryState> createState(List<?> keys, Classifier<? super Throwable, Boolean> classifier) {
    List<RetryState> states = new ArrayList<RetryState>();
    for (Object key : keys) {
      states.add(new DefaultRetryState(key, classifier));
    }
    return states;
  }
View Full Code Here

                      recovered.add(item);
                      return item;
                    }
                  };

                  retryTemplate.execute(callback, recoveryCallback, new DefaultRetryState(item));
                 
                  return RepeatStatus.CONTINUABLE;

                }
View Full Code Here

TOP

Related Classes of org.springframework.retry.support.DefaultRetryState

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.