Package org.springframework.retry

Examples of org.springframework.retry.RetryState


    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

    }

    @Test
    public void test_execute_callableWithState() throws Exception {
        Callable<Long> callable = Mockito.mock(Callable.class);
        RetryState retryState = Mockito.mock(RetryState.class);
        ExtendedRetryTemplate template = new ExtendedRetryTemplate();

        Mockito.when(callable.call()).thenReturn(10L);

        Assert.assertEquals(10L, template.execute(callable, retryState).longValue());
View Full Code Here

    }

    @Test
    public void test_execute_callableWithRecoveryAndState() throws Exception {
        Callable<Long> callable = Mockito.mock(Callable.class);
        RetryState retryState = Mockito.mock(RetryState.class);
        RecoveryCallback<Long> recoveryCallback = Mockito.mock(RecoveryCallback.class);

        ExtendedRetryTemplate template = new ExtendedRetryTemplate();

        Mockito.when(callable.call()).thenReturn(10L);
View Full Code Here

  private RetryPolicy retryPolicy;

  public <T, E extends Throwable> T execute(RetryCallback<T, E> retryCallback, Collection<RetryState> states) throws E,
  Exception {
    RetryState batchState = new BatchRetryState(states);
    return delegate.execute(retryCallback, batchState);
  }
View Full Code Here

    return delegate.execute(retryCallback, batchState);
  }

  public <T, E extends Throwable> T execute(RetryCallback<T, E> retryCallback, RecoveryCallback<T> recoveryCallback,
      Collection<RetryState> states) throws E, Exception {
    RetryState batchState = new BatchRetryState(states);
    return delegate.execute(retryCallback, recoveryCallback, batchState);
  }
View Full Code Here

  }

  @Test
  public void testRegisterThrowable() {
    NeverRetryPolicy retryPolicy = new NeverRetryPolicy();
    RetryState state = new DefaultRetryState("foo");
    RetryContext context = retryTemplate.open(retryPolicy, state);
    assertNotNull(context);
    retryTemplate.registerThrowable(retryPolicy, state, context, new Exception());
    assertFalse(retryPolicy.canRetry(context));
  }
View Full Code Here

  }

  @Test
  public void testClose() throws Exception {
    NeverRetryPolicy retryPolicy = new NeverRetryPolicy();
    RetryState state = new DefaultRetryState("foo");
    RetryContext context = retryTemplate.open(retryPolicy, state);
    assertNotNull(context);
    retryTemplate.registerThrowable(retryPolicy, state, context, new Exception());
    assertFalse(retryPolicy.canRetry(context));
    retryTemplate.close(retryPolicy, context, state, true);
View Full Code Here

TOP

Related Classes of org.springframework.retry.RetryState

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.