@Test
 public void testRabbitTemplateRetry() {
   load(
       TestConfiguration.class,
       "spring.rabbitmq.template.retry.enabled:true",
       "spring.rabbitmq.template.retry.maxAttempts:4",
       "spring.rabbitmq.template.retry.initialInterval:2000",
       "spring.rabbitmq.template.retry.multiplier:1.5",
       "spring.rabbitmq.template.retry.maxInterval:5000",
       "spring.rabbitmq.template.receiveTimeout:123",
       "spring.rabbitmq.template.replyTimeout:456");
   RabbitTemplate rabbitTemplate = this.context.getBean(RabbitTemplate.class);
   DirectFieldAccessor dfa = new DirectFieldAccessor(rabbitTemplate);
   assertThat(dfa.getPropertyValue("receiveTimeout")).isEqualTo(123L);
   assertThat(dfa.getPropertyValue("replyTimeout")).isEqualTo(456L);
   RetryTemplate retryTemplate = (RetryTemplate) dfa.getPropertyValue("retryTemplate");
   assertThat(retryTemplate).isNotNull();
   dfa = new DirectFieldAccessor(retryTemplate);
   SimpleRetryPolicy retryPolicy = (SimpleRetryPolicy) dfa.getPropertyValue("retryPolicy");
   ExponentialBackOffPolicy backOffPolicy =
       (ExponentialBackOffPolicy) dfa.getPropertyValue("backOffPolicy");
   assertThat(retryPolicy.getMaxAttempts()).isEqualTo(4);
   assertThat(backOffPolicy.getInitialInterval()).isEqualTo(2000);
   assertThat(backOffPolicy.getMultiplier()).isEqualTo(1.5);
   assertThat(backOffPolicy.getMaxInterval()).isEqualTo(5000);
 }
  @Override
  public void afterPropertiesSet() throws Exception {
    // we instantiate the connection factory here due to https://jira.spring.io/browse/XD-2647
    ZookeeperConfiguration configuration = new ZookeeperConfiguration(this.zookeeperConnect);
    configuration.setBufferSize(socketBufferSize);
    configuration.setMaxWait(defaultMaxWait);
    DefaultConnectionFactory defaultConnectionFactory = new DefaultConnectionFactory(configuration);
    defaultConnectionFactory.afterPropertiesSet();
    this.connectionFactory = defaultConnectionFactory;
    if (retryOperations == null) {
      RetryTemplate retryTemplate = new RetryTemplate();

      SimpleRetryPolicy simpleRetryPolicy = new SimpleRetryPolicy();
      simpleRetryPolicy.setMaxAttempts(METADATA_VERIFICATION_RETRY_ATTEMPTS);
      retryTemplate.setRetryPolicy(simpleRetryPolicy);

      ExponentialBackOffPolicy backOffPolicy = new ExponentialBackOffPolicy();
      backOffPolicy.setInitialInterval(METADATA_VERIFICATION_RETRY_INITIAL_INTERVAL);
      backOffPolicy.setMultiplier(METADATA_VERIFICATION_RETRY_BACKOFF_MULTIPLIER);
      backOffPolicy.setMaxInterval(METADATA_VERIFICATION_MAX_INTERVAL);
      retryTemplate.setBackOffPolicy(backOffPolicy);
      retryOperations = retryTemplate;
    }
    super.afterPropertiesSet();
  }
 @Test
 public void testRabbitListenerContainerFactoryWithCustomSettings() {
   load(
       MessageConvertersConfiguration.class,
       "spring.rabbitmq.listener.retry.enabled:true",
       "spring.rabbitmq.listener.retry.maxAttempts:4",
       "spring.rabbitmq.listener.retry.initialInterval:2000",
       "spring.rabbitmq.listener.retry.multiplier:1.5",
       "spring.rabbitmq.listener.retry.maxInterval:5000",
       "spring.rabbitmq.listener.autoStartup:false",
       "spring.rabbitmq.listener.acknowledgeMode:manual",
       "spring.rabbitmq.listener.concurrency:5",
       "spring.rabbitmq.listener.maxConcurrency:10",
       "spring.rabbitmq.listener.prefetch:40",
       "spring.rabbitmq.listener.defaultRequeueRejected:false",
       "spring.rabbitmq.listener.transactionSize:20");
   SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory =
       this.context.getBean(
           "rabbitListenerContainerFactory", SimpleRabbitListenerContainerFactory.class);
   DirectFieldAccessor dfa = new DirectFieldAccessor(rabbitListenerContainerFactory);
   assertThat(dfa.getPropertyValue("autoStartup")).isEqualTo(Boolean.FALSE);
   assertThat(dfa.getPropertyValue("acknowledgeMode")).isEqualTo(AcknowledgeMode.MANUAL);
   assertThat(dfa.getPropertyValue("concurrentConsumers")).isEqualTo(5);
   assertThat(dfa.getPropertyValue("maxConcurrentConsumers")).isEqualTo(10);
   assertThat(dfa.getPropertyValue("prefetchCount")).isEqualTo(40);
   assertThat(dfa.getPropertyValue("txSize")).isEqualTo(20);
   assertThat(dfa.getPropertyValue("messageConverter"))
       .isSameAs(this.context.getBean("myMessageConverter"));
   assertThat(dfa.getPropertyValue("defaultRequeueRejected")).isEqualTo(Boolean.FALSE);
   Advice[] adviceChain = (Advice[]) dfa.getPropertyValue("adviceChain");
   assertThat(adviceChain).isNotNull();
   assertThat(adviceChain.length).isEqualTo(1);
   dfa = new DirectFieldAccessor(adviceChain[0]);
   RetryTemplate retryTemplate = (RetryTemplate) dfa.getPropertyValue("retryOperations");
   assertThat(retryTemplate).isNotNull();
   dfa = new DirectFieldAccessor(retryTemplate);
   SimpleRetryPolicy retryPolicy = (SimpleRetryPolicy) dfa.getPropertyValue("retryPolicy");
   ExponentialBackOffPolicy backOffPolicy =
       (ExponentialBackOffPolicy) dfa.getPropertyValue("backOffPolicy");
   assertThat(retryPolicy.getMaxAttempts()).isEqualTo(4);
   assertThat(backOffPolicy.getInitialInterval()).isEqualTo(2000);
   assertThat(backOffPolicy.getMultiplier()).isEqualTo(1.5);
   assertThat(backOffPolicy.getMaxInterval()).isEqualTo(5000);
 }