Search in sources :

Example 6 with SimpleMessageListenerContainer

use of org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer in project spring-integration by spring-projects.

the class ChannelTests method messageConversionTests.

@Test
public void messageConversionTests() throws Exception {
    RabbitTemplate amqpTemplate = new RabbitTemplate(this.connectionFactory);
    MessageConverter messageConverter = mock(MessageConverter.class);
    amqpTemplate.setMessageConverter(messageConverter);
    PointToPointSubscribableAmqpChannel channel = new PointToPointSubscribableAmqpChannel("testConvertFail", new SimpleMessageListenerContainer(this.connectionFactory), amqpTemplate);
    channel.afterPropertiesSet();
    MessageListener listener = TestUtils.getPropertyValue(channel, "container.messageListener", MessageListener.class);
    willThrow(new MessageConversionException("foo", new IllegalStateException("bar"))).given(messageConverter).fromMessage(any(org.springframework.amqp.core.Message.class));
    this.exception.expect(MessageConversionException.class);
    this.exception.expectCause(instanceOf(IllegalStateException.class));
    listener.onMessage(mock(org.springframework.amqp.core.Message.class));
}
Also used : RabbitTemplate(org.springframework.amqp.rabbit.core.RabbitTemplate) MessageConversionException(org.springframework.amqp.support.converter.MessageConversionException) Message(org.springframework.messaging.Message) GenericMessage(org.springframework.messaging.support.GenericMessage) SimpleMessageListenerContainer(org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer) MessageListener(org.springframework.amqp.core.MessageListener) MessageConverter(org.springframework.amqp.support.converter.MessageConverter) Test(org.junit.Test)

Example 7 with SimpleMessageListenerContainer

use of org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer in project spring-integration by spring-projects.

the class Amqp method inboundGateway.

/**
 * Create an initial {@link AmqpInboundGatewaySpec}.
 * @param connectionFactory the connectionFactory.
 * @param queueNames the queueNames.
 * @return the AmqpInboundGatewaySpec.
 */
public static AmqpInboundGatewaySMLCSpec inboundGateway(ConnectionFactory connectionFactory, String... queueNames) {
    SimpleMessageListenerContainer listenerContainer = new SimpleMessageListenerContainer(connectionFactory);
    listenerContainer.setQueueNames(queueNames);
    return inboundGateway(listenerContainer);
}
Also used : SimpleMessageListenerContainer(org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer)

Example 8 with SimpleMessageListenerContainer

use of org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer in project spring-integration by spring-projects.

the class Amqp method inboundGateway.

/**
 * Create an initial {@link AmqpInboundGatewaySpec}.
 * @param connectionFactory the connectionFactory.
 * @param queues the queues.
 * @return the AmqpInboundGatewaySpec.
 */
public static AmqpInboundGatewaySMLCSpec inboundGateway(ConnectionFactory connectionFactory, Queue... queues) {
    SimpleMessageListenerContainer listenerContainer = new SimpleMessageListenerContainer(connectionFactory);
    listenerContainer.setQueues(queues);
    return inboundGateway(listenerContainer);
}
Also used : SimpleMessageListenerContainer(org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer)

Example 9 with SimpleMessageListenerContainer

use of org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer in project spring-integration by spring-projects.

the class Amqp method inboundAdapter.

/**
 * Create an initial AmqpInboundChannelAdapterSpec using a
 * {@link SimpleMessageListenerContainer}.
 * @param connectionFactory the connectionFactory.
 * @param queues the queues.
 * @return the AmqpInboundChannelAdapterSpec.
 */
public static AmqpInboundChannelAdapterSMLCSpec inboundAdapter(ConnectionFactory connectionFactory, Queue... queues) {
    SimpleMessageListenerContainer listenerContainer = new SimpleMessageListenerContainer(connectionFactory);
    listenerContainer.setQueues(queues);
    return new AmqpInboundChannelAdapterSMLCSpec(listenerContainer);
}
Also used : SimpleMessageListenerContainer(org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer)

Example 10 with SimpleMessageListenerContainer

use of org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer in project spring-integration by spring-projects.

the class Amqp method inboundGateway.

/**
 * Create an initial {@link AmqpInboundGatewaySpec}.
 * @param connectionFactory the connectionFactory.
 * @param amqpTemplate the {@link AmqpTemplate} to use.
 * @param queueNames the queueNames.
 * @return the AmqpInboundGatewaySpec.
 */
public static AmqpInboundGatewaySMLCSpec inboundGateway(ConnectionFactory connectionFactory, AmqpTemplate amqpTemplate, String... queueNames) {
    SimpleMessageListenerContainer listenerContainer = new SimpleMessageListenerContainer(connectionFactory);
    listenerContainer.setQueueNames(queueNames);
    return inboundGateway(listenerContainer, amqpTemplate);
}
Also used : SimpleMessageListenerContainer(org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer)

Aggregations

SimpleMessageListenerContainer (org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer)27 Test (org.junit.Test)13 ConnectionFactory (org.springframework.amqp.rabbit.connection.ConnectionFactory)10 BeanFactory (org.springframework.beans.factory.BeanFactory)8 DirectChannel (org.springframework.integration.channel.DirectChannel)8 QueueChannel (org.springframework.integration.channel.QueueChannel)8 Channel (com.rabbitmq.client.Channel)7 MessageProperties (org.springframework.amqp.core.MessageProperties)7 Connection (org.springframework.amqp.rabbit.connection.Connection)7 ChannelAwareMessageListener (org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener)7 Jackson2JsonMessageConverter (org.springframework.amqp.support.converter.Jackson2JsonMessageConverter)5 Bean (org.springframework.context.annotation.Bean)5 Message (org.springframework.messaging.Message)5 PollableChannel (org.springframework.messaging.PollableChannel)5 GenericMessage (org.springframework.messaging.support.GenericMessage)5 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 RabbitTemplate (org.springframework.amqp.rabbit.core.RabbitTemplate)4 AbstractMessageListenerContainer (org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer)4 MessageConversionException (org.springframework.amqp.support.converter.MessageConversionException)4 MessageConverter (org.springframework.amqp.support.converter.MessageConverter)4