Examples of RetryTemplate


Examples of org.springframework.retry.support.RetryTemplate

   * @param properties The properties.
   * @return The channel, or a wrapper.
   */
  private MessageChannel addRetryIfNeeded(final String name, final DirectChannel bridgeToModuleChannel,
      RedisPropertiesAccessor properties) {
    final RetryTemplate retryTemplate = buildRetryTemplateIfRetryEnabled(properties);
    if (retryTemplate == null) {
      return bridgeToModuleChannel;
    }
    else {
      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

Examples of org.springframework.retry.support.RetryTemplate

    assertThat(
        channel.getClass().getName(), containsString("RedisMessageBus$")); // retry wrapper
    assertThat(
        TestUtils.getPropertyValue(TestUtils.getPropertyValue(endpoint, "consumers", List.class).get(1),
            "outputChannel").getClass().getName(), containsString("RedisMessageBus$")); // retry wrapper
    RetryTemplate retry = TestUtils.getPropertyValue(channel, "val$retryTemplate", RetryTemplate.class);
    assertEquals(23, TestUtils.getPropertyValue(retry, "retryPolicy.maxAttempts"));
    assertEquals(2000L, TestUtils.getPropertyValue(retry, "backOffPolicy.initialInterval"));
    assertEquals(20000L, TestUtils.getPropertyValue(retry, "backOffPolicy.maxInterval"));
    assertEquals(5.0, TestUtils.getPropertyValue(retry, "backOffPolicy.multiplier"));
  }
View Full Code Here

Examples of org.springframework.retry.support.RetryTemplate

        /**
         * Do not have Spring AMQP re-try messages upon failure, leave it to Camel
         * @return An advice chain populated with a NeverRetryPolicy
         */
        public final Advice[] getAdviceChain() {
            RetryTemplate retryRule = new RetryTemplate();
            retryRule.setRetryPolicy(new NeverRetryPolicy());
           
            StatefulRetryOperationsInterceptorFactoryBean retryOperation = new StatefulRetryOperationsInterceptorFactoryBean();
            retryOperation.setRetryOperations(retryRule);
            retryOperation.setMessageKeyGeneretor(new DefaultKeyGenerator());
           
View Full Code Here

Examples of org.springframework.retry.support.RetryTemplate

        /**
         * Do not have Spring AMQP re-try messages upon failure, leave it to Camel
         * @return An advice chain populated with a NeverRetryPolicy
         */
        public final Advice[] getAdviceChain() {
            RetryTemplate retryRule = new RetryTemplate();
            retryRule.setRetryPolicy(new NeverRetryPolicy());
           
            StatefulRetryOperationsInterceptorFactoryBean retryOperation = new StatefulRetryOperationsInterceptorFactoryBean();
            retryOperation.setRetryOperations(retryRule);
            retryOperation.setMessageKeyGeneretor(new DefaultKeyGenerator());
           
View Full Code Here

Examples of org.springframework.retry.support.RetryTemplate

    assertEquals(2, count);
  }

  @Test
  public void testDefaultInterceptorWithRecovery() throws Exception {
    RetryTemplate template = new RetryTemplate();
    template.setRetryPolicy(new SimpleRetryPolicy(1, Collections
        .<Class<? extends Throwable>, Boolean> singletonMap(Exception.class, true)));
    interceptor.setRetryOperations(template);
    interceptor.setRecoverer(new MethodInvocationRecoverer<Void>() {
      public Void recover(Object[] args, Throwable cause) {
        return null;
View Full Code Here

Examples of org.springframework.retry.support.RetryTemplate

      public Object invoke(MethodInvocation invocation) throws Throwable {
        list.add("chain");
        return invocation.proceed();
      }
    });
    RetryTemplate template = new RetryTemplate();
    template.setRetryPolicy(new SimpleRetryPolicy(2, Collections
        .<Class<? extends Throwable>, Boolean> singletonMap(Exception.class, true)));
    interceptor.setRetryOperations(template);
    service.service();
    assertEquals(2, count);
    assertEquals(2, list.size());
View Full Code Here

Examples of org.springframework.retry.support.RetryTemplate

  }

  @Test
  public void testRetryExceptionAfterTooManyAttempts() throws Exception {
    ((Advised) service).addAdvice(interceptor);
    RetryTemplate template = new RetryTemplate();
    template.setRetryPolicy(new NeverRetryPolicy());
    interceptor.setRetryOperations(template);
    try {
      service.service();
      fail("Expected Exception.");
    }
View Full Code Here

Examples of org.springframework.retry.support.RetryTemplate

    assertEquals(3, TestUtils.getPropertyValue(interceptor, "retryOperations.retryPolicy.maxAttempts"));
  }

  @Test
  public void testWithCustomRetryTemplate() {
    RetryOperations retryOperations = new RetryTemplate();
    StatefulRetryOperationsInterceptor interceptor = RetryInterceptorBuilder.stateful()
        .retryOperations(retryOperations)
        .build();
    assertEquals(3, TestUtils.getPropertyValue(interceptor, "retryOperations.retryPolicy.maxAttempts"));
    assertSame(retryOperations, TestUtils.getPropertyValue(interceptor, "retryOperations"));
View Full Code Here

Examples of org.springframework.retry.support.RetryTemplate

        /**
         * Do not have Spring AMQP re-try messages upon failure, leave it to Camel
         * @return An advice chain populated with a NeverRetryPolicy
         */
        public final Advice[] getAdviceChain() {
            RetryTemplate retryRule = new RetryTemplate();
            retryRule.setRetryPolicy(new NeverRetryPolicy());
           
            StatefulRetryOperationsInterceptorFactoryBean retryOperation = new StatefulRetryOperationsInterceptorFactoryBean();
            retryOperation.setRetryOperations(retryRule);
            retryOperation.setMessageKeyGeneretor(new DefaultKeyGenerator());
           
View Full Code Here

Examples of org.springframework.retry.support.RetryTemplate

    SimpleMessageConverter messageConverter = new SimpleMessageConverter();
    // There will be no key for these messages so they cannot be recovered...
    messageConverter.setCreateMessageIds(false);
    this.messageConverter = messageConverter;
    // Beware of context cache busting if retry policy fails...
    this.retryTemplate = new RetryTemplate();
    this.retryTemplate.setRetryContextCache(new MapRetryContextCache(1));
    // The container should have shutdown, so there are now no active consumers
    exception.handleAssertionErrors();
    exception.expectMessage("expected:<1> but was:<0>");
    doTestStatefulRetry(messageCount, txSize, failFrequency, concurrentConsumers);
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.