Example usage for org.springframework.amqp.rabbit.listener DirectReplyToMessageListenerContainer start

List of usage examples for org.springframework.amqp.rabbit.listener DirectReplyToMessageListenerContainer start

Introduction

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

Prototype

@Override
public void start() 

Source Link

Document

Start this container.

Usage

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  w  w w . java2s  . c om
    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.DirectMessageListenerContainerIntegrationTests.java

@Test
public void testReplyToConsumersReduced() throws Exception {
    CachingConnectionFactory cf = new CachingConnectionFactory("localhost");
    DirectReplyToMessageListenerContainer container = new DirectReplyToMessageListenerContainer(cf);
    container.setBeanName("reducing");
    container.setIdleEventInterval(500);
    container.afterPropertiesSet();//from ww  w  . java2 s  . c o m
    container.start();
    ChannelHolder channelHolder = container.getChannelHolder();
    assertTrue(activeConsumerCount(container, 1));
    container.releaseConsumerFor(channelHolder, false, null);
    assertTrue(activeConsumerCount(container, 0));
    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 ww w  . j a  va  2s .  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));
}

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

@Test
public void testReplyToConsumersReduced() throws Exception {
    CachingConnectionFactory cf = new CachingConnectionFactory("localhost");
    DirectReplyToMessageListenerContainer container = new DirectReplyToMessageListenerContainer(cf);
    container.setBeanName("reducing");
    container.setIdleEventInterval(500);
    container.afterPropertiesSet();// www  . ja v a  2 s  . com
    container.start();
    ChannelHolder channelHolder = container.getChannelHolder();
    assertTrue(activeConsumerCount(container, 1));
    container.releaseConsumerFor(channelHolder, false, null);
    assertTrue(activeConsumerCount(container, 0));
}