Example usage for org.springframework.amqp.rabbit.listener SimpleMessageListenerContainer setFailedDeclarationRetryInterval

List of usage examples for org.springframework.amqp.rabbit.listener SimpleMessageListenerContainer setFailedDeclarationRetryInterval

Introduction

In this page you can find the example usage for org.springframework.amqp.rabbit.listener SimpleMessageListenerContainer setFailedDeclarationRetryInterval.

Prototype

public void setFailedDeclarationRetryInterval(long failedDeclarationRetryInterval) 

Source Link

Document

Set the interval between passive queue declaration attempts in milliseconds.

Usage

From source file:org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainerIntegration2Tests.java

@Test
public void testRestartConsumerMissingQueue() throws Exception {
    Queue queue = new AnonymousQueue();
    this.template.convertAndSend(queue.getName(), "foo");

    ConnectionFactory connectionFactory = new CachingConnectionFactory("localhost", BrokerTestUtils.getPort());

    CountDownLatch latch = new CountDownLatch(1);
    SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(connectionFactory);
    container.setMessageListener(new MessageListenerAdapter(new PojoListener(latch)));
    container.setQueues(queue);//from  w  w  w  .j a  v a 2s . co  m
    container.setRecoveryInterval(500);
    container.setMissingQueuesFatal(false);
    container.setDeclarationRetries(1);
    container.setFailedDeclarationRetryInterval(100);
    container.setRetryDeclarationInterval(30000);
    container.afterPropertiesSet();
    container.start();

    new RabbitAdmin(connectionFactory).declareQueue(queue);
    this.template.convertAndSend(queue.getName(), "foo");

    assertTrue(latch.await(10, TimeUnit.SECONDS));

    // verify properties propagated to consumer
    BlockingQueueConsumer consumer = (BlockingQueueConsumer) TestUtils
            .getPropertyValue(container, "consumers", Map.class).keySet().iterator().next();
    assertEquals(1, TestUtils.getPropertyValue(consumer, "declarationRetries"));
    assertEquals(100L, TestUtils.getPropertyValue(consumer, "failedDeclarationRetryInterval"));
    assertEquals(30000L, TestUtils.getPropertyValue(consumer, "retryDeclarationInterval"));

    container.stop();
    ((DisposableBean) connectionFactory).destroy();
}