Example usage for org.springframework.integration.amqp.channel PointToPointSubscribableAmqpChannel PointToPointSubscribableAmqpChannel

List of usage examples for org.springframework.integration.amqp.channel PointToPointSubscribableAmqpChannel PointToPointSubscribableAmqpChannel

Introduction

In this page you can find the example usage for org.springframework.integration.amqp.channel PointToPointSubscribableAmqpChannel PointToPointSubscribableAmqpChannel.

Prototype

public PointToPointSubscribableAmqpChannel(String channelName, AbstractMessageListenerContainer container,
        AmqpTemplate amqpTemplate) 

Source Link

Document

Construct an instance with the supplied name, container and template; default header mappers will be used if the message is mapped.

Usage

From source file:org.springframework.integration.amqp.channel.DispatcherHasNoSubscribersTests.java

@Test
public void testPtP() {
    final Channel channel = mock(Channel.class);
    Connection connection = mock(Connection.class);
    doAnswer(new Answer<Channel>() {
        public Channel answer(InvocationOnMock invocation) throws Throwable {
            return channel;
        }/* www  .j  ava 2 s .co m*/
    }).when(connection).createChannel(anyBoolean());
    ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
    when(connectionFactory.createConnection()).thenReturn(connection);
    SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
    container.setConnectionFactory(connectionFactory);
    AmqpTemplate amqpTemplate = mock(AmqpTemplate.class);

    PointToPointSubscribableAmqpChannel amqpChannel = new PointToPointSubscribableAmqpChannel(
            "noSubscribersChannel", container, amqpTemplate);
    amqpChannel.setBeanName("noSubscribersChannel");
    amqpChannel.afterPropertiesSet();

    MessageListener listener = (MessageListener) container.getMessageListener();
    try {
        listener.onMessage(new Message("Hello world!".getBytes(), null));
        fail("Exception expected");
    } catch (MessageDeliveryException e) {
        assertEquals("Dispatcher has no subscribers for amqp-channel 'noSubscribersChannel'.", e.getMessage());
    }
}