Example usage for org.springframework.amqp.rabbit.listener DirectMessageListenerContainer setMissingQueuesFatal

List of usage examples for org.springframework.amqp.rabbit.listener DirectMessageListenerContainer setMissingQueuesFatal

Introduction

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

Prototype

@Override
public final void setMissingQueuesFatal(boolean missingQueuesFatal) 

Source Link

Document

Defaults to false for this container.

Usage

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

@Test
public void testContainerNotRecoveredAfterExhaustingRecoveryBackOff() throws Exception {
    ConnectionFactory mockCF = mock(ConnectionFactory.class);
    given(mockCF.createConnection()).willThrow(new RuntimeException("intended - backOff test"));
    DirectMessageListenerContainer container = new DirectMessageListenerContainer(mockCF);
    container.setQueueNames("foo");
    container.setRecoveryBackOff(new FixedBackOff(100, 3));
    container.setMissingQueuesFatal(false);
    container.setBeanName("backOff");
    container.setConsumerTagStrategy(new Tag());
    container.afterPropertiesSet();/*from   w  ww. java  2s.  com*/
    container.start();

    // Since backOff exhausting makes listenerContainer as invalid (calls stop()),
    // it is enough to check the listenerContainer activity
    int n = 0;
    while (container.isActive() && n++ < 100) {
        Thread.sleep(100);
    }
    assertFalse(container.isActive());
}