List of usage examples for org.springframework.amqp.rabbit.listener DirectReplyToMessageListenerContainer setApplicationEventPublisher
@Override public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)
From source file:org.springframework.amqp.rabbit.listener.DirectMessageListenerContainerIntegrationTests.java
@Test public void testReplyToReleaseWithCancel() throws Exception { CachingConnectionFactory cf = new CachingConnectionFactory("localhost"); DirectReplyToMessageListenerContainer container = new DirectReplyToMessageListenerContainer(cf); container.setBeanName("releaseCancel"); container.afterPropertiesSet();/*from ww w . j av a2 s . co m*/ container.start(); ChannelHolder channelHolder = container.getChannelHolder(); final CountDownLatch latch = new CountDownLatch(1); container.setApplicationEventPublisher(e -> { if (e instanceof ListenerContainerConsumerTerminatedEvent) { latch.countDown(); } }); container.releaseConsumerFor(channelHolder, true, "foo"); assertTrue(latch.await(10, TimeUnit.SECONDS)); container.stop(); cf.destroy(); }
From source file:org.springframework.amqp.rabbit.listener.DirectMessageListenerContainerTests.java
@Test public void testReplyToReleaseWithCancel() throws Exception { CachingConnectionFactory cf = new CachingConnectionFactory("localhost"); DirectReplyToMessageListenerContainer container = new DirectReplyToMessageListenerContainer(cf); container.setBeanName("releaseCancel"); container.afterPropertiesSet();/*from w w w . jav a 2 s . c o m*/ container.start(); ChannelHolder channelHolder = container.getChannelHolder(); final CountDownLatch latch = new CountDownLatch(1); container.setApplicationEventPublisher(e -> { if (e instanceof ListenerContainerConsumerTerminatedEvent) { latch.countDown(); } }); container.releaseConsumerFor(channelHolder, true, "foo"); assertTrue(latch.await(10, TimeUnit.SECONDS)); }