public class SpringAMQPMessageSource extends Object implements org.springframework.amqp.rabbit.core.ChannelAwareMessageListener, SubscribableMessageSource<EventMessage<?>>
The SpringAMQPMessageSource must be registered with a Spring MessageListenerContainer and forwards each message to all subscribed processors.
Note that the Processors must be subscribed before the MessageListenerContainer is started. Otherwise, messages will be consumed from the AMQP Queue without any processor processing them.
Constructor and Description |
---|
SpringAMQPMessageSource(AMQPMessageConverter messageConverter)
Initializes an SpringAMQPMessageSource with given
messageConverter to convert the incoming AMQP
message into an EventMessage. |
SpringAMQPMessageSource(Serializer serializer)
Initializes an SpringAMQPMessageSource with
DefaultAMQPMessageConverter using given serializer . |
Modifier and Type | Method and Description |
---|---|
void |
onMessage(org.springframework.amqp.core.Message message,
com.rabbitmq.client.Channel channel) |
Registration |
subscribe(Consumer<List<? extends EventMessage<?>>> messageProcessor)
Subscribe the given
messageProcessor to this message source. |
public SpringAMQPMessageSource(Serializer serializer)
DefaultAMQPMessageConverter
using given serializer
.serializer
- The serializer to serialize payload and metadata of eventspublic SpringAMQPMessageSource(AMQPMessageConverter messageConverter)
messageConverter
to convert the incoming AMQP
message into an EventMessage.messageConverter
- The message converter to use to convert AMQP Messages to Event Messagespublic Registration subscribe(Consumer<List<? extends EventMessage<?>>> messageProcessor)
SubscribableMessageSource
messageProcessor
to this message source. When subscribed, it will receive all
messages published to this source.
If the given messageProcessor
is already subscribed, nothing happens.
subscribe
in interface SubscribableMessageSource<EventMessage<?>>
messageProcessor
- The message processor to subscribemessageProcessor
. When unsubscribed it will no longer receive
messages.public void onMessage(org.springframework.amqp.core.Message message, com.rabbitmq.client.Channel channel)
onMessage
in interface org.springframework.amqp.rabbit.core.ChannelAwareMessageListener
Copyright © 2010–2018. All rights reserved.