/** * Create an instance; {@link #setConnectionFactory(ConnectionFactory)} must * be called before starting. */ public DirectMessageListenerContainer() { setMissingQueuesFatal(false); }
/** * Create an instance; {@link #setConnectionFactory(ConnectionFactory)} must * be called before starting. */ public DirectMessageListenerContainer() { setMissingQueuesFatal(false); }
/** * Create an instance with the provided connection factory. * @param connectionFactory the connection factory. */ public DirectMessageListenerContainer(ConnectionFactory connectionFactory) { setConnectionFactory(connectionFactory); setMissingQueuesFatal(false); }
/** * Create an instance with the provided connection factory. * @param connectionFactory the connection factory. */ public DirectMessageListenerContainer(ConnectionFactory connectionFactory) { setConnectionFactory(connectionFactory); setMissingQueuesFatal(false); }
@Test public void testContainerNotRecoveredAfterExhaustingRecoveryBackOff() throws Exception { ConnectionFactory mockCF = mock(ConnectionFactory.class); given(mockCF.createConnection()).willReturn(null).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(); 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()); }