Package org.springframework.retry.support

Examples of org.springframework.retry.support.RetryTemplate.execute()


        .<Class<? extends Throwable>, Boolean> singletonMap(Exception.class, true)));

    assertFalse(cache.containsKey("foo"));

    try {
      retryTemplate.execute(callback, retryState);
      // The first failed attempt we expect to retry...
      fail("Expected RuntimeException");
    }
    catch (RuntimeException e) {
      assertEquals(null, e.getMessage());
View Full Code Here


    }

    assertTrue(cache.containsKey("foo"));

    try {
      retryTemplate.execute(callback, retryState);
      // We don't get a second attempt...
      fail("Expected ExhaustedRetryException");
    }
    catch (ExhaustedRetryException e) {
      // This is now the "exhausted" message:
View Full Code Here

    assertFalse(cache.containsKey("foo"));

    Object result = "start_foo";
    try {
      result = retryTemplate.execute(callback, retryState);
      // The first failed attempt we expect to retry...
      fail("Expected RuntimeException");
    }
    catch (RuntimeException e) {
      assertNull(e.getMessage());
View Full Code Here

      assertNull(e.getMessage());
    }

    assertTrue(cache.containsKey("foo"));

    result = retryTemplate.execute(callback, retryState);

    assertFalse(cache.containsKey("foo"));

    assertEquals(2, callback.attempts);
    assertEquals("bar", result);
View Full Code Here

    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());
            throw new Exception("Fail");
          }
        }, new RecoveryCallback<String>() {
View Full Code Here

      }
    };

    Object result = null;
    try {
      result = retryTemplate.execute(callback, recoveryCallback);
    }
    catch (IllegalArgumentException e) {
      // We should swallow the exception when recovery is possible
      fail("Did not expect IllegalArgumentException");
    }
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
View Full Code Here

    }
    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

                throw new IllegalStateException(e);
              }
              return msg;
            }
          };
          retryTemplate.execute(callback, recoveryCallback, new DefaultRetryState(msg.getJMSMessageID()));
        }
        catch (Exception e) {
          throw (RuntimeException) e;
        }
      }
View Full Code Here

      DirectChannel channel = new DirectChannel() {

        @Override
        protected boolean doSend(final Message<?> message, final long timeout) {
          try {
            return retryTemplate.execute(new RetryCallback<Boolean, Exception>() {

              @Override
              public Boolean doWithRetry(RetryContext context) throws Exception {
                return bridgeToModuleChannel.send(message, timeout);
              }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.