@AfterAll public static void tearDown(ConfigurableApplicationContext context) { context.stop(); // prevent queues from being redeclared after deletion RabbitAvailableCondition.getBrokerRunning().removeTestQueues("si.dsl.exception.test", "si.dsl.conv.exception.test"); }
@Bean public CachingConnectionFactory cf() { return new CachingConnectionFactory( RabbitAvailableCondition.getBrokerRunning().getConnectionFactory()); }
@Bean public CachingConnectionFactory cf() { return new CachingConnectionFactory(RabbitAvailableCondition.getBrokerRunning() .getConnectionFactory()); }
@Bean public ConnectionFactory connectionFactory() { return new CachingConnectionFactory(RabbitAvailableCondition.getBrokerRunning().getConnectionFactory()); }
@Bean public CachingConnectionFactory ccf() { return new CachingConnectionFactory(RabbitAvailableCondition.getBrokerRunning().getConnectionFactory()); }
@Test public void testDeferredChannelCacheNack() throws Exception { final CachingConnectionFactory cf = new CachingConnectionFactory( RabbitAvailableCondition.getBrokerRunning().getConnectionFactory()); cf.setPublisherReturns(true); cf.setPublisherConfirms(true);
@Test public void testDeferredChannelCacheAck() throws Exception { final CachingConnectionFactory cf = new CachingConnectionFactory( RabbitAvailableCondition.getBrokerRunning().getConnectionFactory()); cf.setPublisherConfirms(true); final RabbitTemplate template = new RabbitTemplate(cf); final CountDownLatch confirmLatch = new CountDownLatch(1); final AtomicInteger cacheCount = new AtomicInteger(); template.setConfirmCallback((cd, a, c) -> { cacheCount.set(TestUtils.getPropertyValue(cf, "cachedChannelsNonTransactional", List.class).size()); confirmLatch.countDown(); }); template.setMandatory(true); Connection conn = cf.createConnection(); Channel channel1 = conn.createChannel(false); Channel channel2 = conn.createChannel(false); channel1.close(); channel2.close(); conn.close(); assertThat(TestUtils.getPropertyValue(cf, "cachedChannelsNonTransactional", List.class).size()).isEqualTo(2); template.convertAndSend("", QUEUE2, "foo", new MyCD("foo")); assertThat(confirmLatch.await(10, TimeUnit.SECONDS)).isTrue(); assertThat(cacheCount.get()).isEqualTo(1); cf.destroy(); }