Package org.springframework.retry.support

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


        /**
         * 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

    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

      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

  }

  @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

    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

        /**
         * 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

    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

        logger.info("Recovered: [" + SerializationUtils.deserialize(message.getBody()).toString()+"], message: " +message);
        latch.countDown();
      }
    });
    if (retryTemplate == null) {
      retryTemplate = new RetryTemplate();
    }
    factory.setRetryOperations(retryTemplate);
    Advice retryInterceptor = factory.getObject();
    return retryInterceptor;
  }
View Full Code Here

    container.setQueueNames("retry.test.queue");

    StatefulRetryOperationsInterceptorFactoryBean fb = new StatefulRetryOperationsInterceptorFactoryBean();

    // use an external template so we can share his cache
    RetryTemplate retryTemplate = new RetryTemplate();
    RetryContextCache cache = new MapRetryContextCache();
    retryTemplate.setRetryContextCache(cache);
    fb.setRetryOperations(retryTemplate);

    // give him a reference to the retry cache so he can clean it up
    MissingMessageIdAdvice missingIdAdvice = new MissingMessageIdAdvice(cache);
View Full Code Here

TOP

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

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.