public class MessagingMessageListenerAdapter extends AbstractAdaptableMessageListener
MessageListener
adapter that invokes a configurable HandlerAdapter
.
Wraps the incoming AMQP Message
to Spring's Message
abstraction, copying the
standard headers using a configurable
AmqpHeaderMapper
.
The original Message
and
the Channel
are provided as additional arguments so that these can
be injected as method arguments if necessary.
AbstractAdaptableMessageListener.ReplyExpressionRoot, AbstractAdaptableMessageListener.ResultHolder
logger
Constructor and Description |
---|
MessagingMessageListenerAdapter() |
MessagingMessageListenerAdapter(Object bean,
Method method) |
MessagingMessageListenerAdapter(Object bean,
Method method,
boolean returnExceptions,
RabbitListenerErrorHandler errorHandler) |
Modifier and Type | Method and Description |
---|---|
protected Message |
buildMessage(com.rabbitmq.client.Channel channel,
Object result)
Build a Rabbit message to be sent as response based on the given result object.
|
protected MessagingMessageConverter |
getMessagingMessageConverter() |
void |
onMessage(Message amqpMessage,
com.rabbitmq.client.Channel channel)
Callback for processing a received Rabbit message.
|
void |
setHandlerMethod(HandlerAdapter handlerMethod)
Set the
HandlerAdapter to use to invoke the method
processing an incoming Message . |
void |
setHeaderMapper(AmqpHeaderMapper headerMapper)
Set the
AmqpHeaderMapper implementation to use to map the standard
AMQP headers. |
protected org.springframework.messaging.Message<?> |
toMessagingMessage(Message amqpMessage) |
extractMessage, getEncoding, getMessageConverter, getReceivedExchange, getReplyToAddress, handleListenerException, handleResult, handleResult, onMessage, postProcessChannel, postProcessResponse, sendResponse, setBeanResolver, setEncoding, setMandatoryPublish, setMessageConverter, setReplyPostProcessor, setResponseAddress, setResponseExchange, setResponseRoutingKey
public MessagingMessageListenerAdapter()
public MessagingMessageListenerAdapter(Object bean, Method method, boolean returnExceptions, RabbitListenerErrorHandler errorHandler)
public void setHandlerMethod(HandlerAdapter handlerMethod)
HandlerAdapter
to use to invoke the method
processing an incoming Message
.handlerMethod
- HandlerAdapter
instance.public void setHeaderMapper(AmqpHeaderMapper headerMapper)
AmqpHeaderMapper
implementation to use to map the standard
AMQP headers. By default, a SimpleAmqpHeaderMapper
is used.headerMapper
- the AmqpHeaderMapper
instance.SimpleAmqpHeaderMapper
protected final MessagingMessageConverter getMessagingMessageConverter()
MessagingMessageConverter
for this listener,
being able to convert Message
.public void onMessage(Message amqpMessage, com.rabbitmq.client.Channel channel) throws Exception
ChannelAwareMessageListener
Implementors are supposed to process the given Message, typically sending reply messages through the given Session.
amqpMessage
- the received AMQP message (never null
)channel
- the underlying Rabbit Channel (never null
)Exception
- Any.protected org.springframework.messaging.Message<?> toMessagingMessage(Message amqpMessage)
protected Message buildMessage(com.rabbitmq.client.Channel channel, Object result) throws Exception
buildMessage
in class AbstractAdaptableMessageListener
channel
- the Rabbit Channel to operate onresult
- the content of the message, as returned from the listener methodMessage
(never null
)Exception
- if thrown by Rabbit API methodsAbstractAdaptableMessageListener.setMessageConverter(org.springframework.amqp.support.converter.MessageConverter)