Class MessagingMessageListenerAdapter
java.lang.Object
org.springframework.amqp.rabbit.listener.adapter.AbstractAdaptableMessageListener
org.springframework.amqp.rabbit.listener.adapter.MessagingMessageListenerAdapter
- All Implemented Interfaces:
MessageListener,ChannelAwareMessageListener
- Direct Known Subclasses:
BatchMessagingMessageListenerAdapter,StreamMessageListenerAdapter
A
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.
- Since:
- 1.4
- Author:
- Stephane Nicoll, Gary Russell, Artem Bilan, Kai Stapel
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected final classDelegates payload extraction toAbstractAdaptableMessageListener.extractMessage(org.springframework.amqp.core.Message message)to enforce backward compatibility.Nested classes/interfaces inherited from class org.springframework.amqp.rabbit.listener.adapter.AbstractAdaptableMessageListener
AbstractAdaptableMessageListener.ReplyExpressionRoot -
Field Summary
Fields inherited from class org.springframework.amqp.rabbit.listener.adapter.AbstractAdaptableMessageListener
logger -
Constructor Summary
ConstructorsModifierConstructorDescriptionMessagingMessageListenerAdapter(Object bean, Method method) MessagingMessageListenerAdapter(Object bean, Method method, boolean returnExceptions, RabbitListenerErrorHandler errorHandler) protectedMessagingMessageListenerAdapter(Object bean, Method method, boolean returnExceptions, RabbitListenerErrorHandler errorHandler, boolean batch) -
Method Summary
Modifier and TypeMethodDescriptionprotected MessagebuildMessage(com.rabbitmq.client.Channel channel, Object result, Type genericType) Build a Rabbit message to be sent as response based on the given result object.protected HandlerAdapterprotected final MessagingMessageConverterprotected voidinvokeHandlerAndProcessResult(Message amqpMessage, com.rabbitmq.client.Channel channel, Message<?> message) booleanReturn true if this listener is request/reply and the replies are async.voidCallback for processing a received Rabbit message.voidsetHandlerAdapter(HandlerAdapter handlerAdapter) Set theHandlerAdapterto use to invoke the method processing an incomingMessage.voidsetHeaderMapper(AmqpHeaderMapper headerMapper) Set theAmqpHeaderMapperimplementation to use to map the standard AMQP headers.voidsetMessageConverter(MessageConverter messageConverter) Set the converter that will convert incoming Rabbit messages to listener method arguments, and objects returned from listener methods back to Rabbit messages.protected Message<?>toMessagingMessage(Message amqpMessage) Methods inherited from class org.springframework.amqp.rabbit.listener.adapter.AbstractAdaptableMessageListener
containerAckMode, convert, doHandleResult, doPublish, extractMessage, getEncoding, getMessageConverter, getReceivedExchange, getReplyContentType, getReplyToAddress, handleListenerException, handleResult, handleResult, isConverterWinsContentType, postProcessChannel, postProcessResponse, sendResponse, setBeanResolver, setBeforeSendReplyPostProcessors, setConverterWinsContentType, setDefaultRequeueRejected, setEncoding, setMandatoryPublish, setRecoveryCallback, setReplyContentType, setReplyPostProcessor, setResponseAddress, setResponseExchange, setResponseRoutingKey, setRetryTemplateMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener
onMessage, onMessageBatchMethods inherited from interface org.springframework.amqp.core.MessageListener
onMessageBatch
-
Constructor Details
-
MessagingMessageListenerAdapter
public MessagingMessageListenerAdapter() -
MessagingMessageListenerAdapter
-
MessagingMessageListenerAdapter
public MessagingMessageListenerAdapter(Object bean, Method method, boolean returnExceptions, RabbitListenerErrorHandler errorHandler) -
MessagingMessageListenerAdapter
protected MessagingMessageListenerAdapter(Object bean, Method method, boolean returnExceptions, RabbitListenerErrorHandler errorHandler, boolean batch)
-
-
Method Details
-
setHandlerAdapter
Set theHandlerAdapterto use to invoke the method processing an incomingMessage.- Parameters:
handlerAdapter-HandlerAdapterinstance.
-
getHandlerAdapter
-
isAsyncReplies
public boolean isAsyncReplies()Description copied from interface:MessageListenerReturn true if this listener is request/reply and the replies are async.- Returns:
- true for async replies.
-
setHeaderMapper
Set theAmqpHeaderMapperimplementation to use to map the standard AMQP headers. By default, aSimpleAmqpHeaderMapperis used.- Parameters:
headerMapper- theAmqpHeaderMapperinstance.- See Also:
-
getMessagingMessageConverter
- Returns:
- the
MessagingMessageConverterfor this listener, being able to convertMessage.
-
setMessageConverter
Description copied from class:AbstractAdaptableMessageListenerSet the converter that will convert incoming Rabbit messages to listener method arguments, and objects returned from listener methods back to Rabbit messages.The default converter is a
SimpleMessageConverter, which is able to handle "text" content-types.- Overrides:
setMessageConverterin classAbstractAdaptableMessageListener- Parameters:
messageConverter- The message converter.
-
onMessage
Description copied from interface:ChannelAwareMessageListenerCallback for processing a received Rabbit message.Implementors are supposed to process the given Message, typically sending reply messages through the given Session.
- Parameters:
amqpMessage- the received AMQP message (nevernull)channel- the underlying Rabbit Channel (nevernullunless called by the stream listener container).- Throws:
Exception- Any.
-
invokeHandlerAndProcessResult
protected void invokeHandlerAndProcessResult(@Nullable Message amqpMessage, com.rabbitmq.client.Channel channel, Message<?> message) throws Exception - Throws:
Exception
-
toMessagingMessage
-
buildMessage
protected Message buildMessage(com.rabbitmq.client.Channel channel, Object result, Type genericType) Build a Rabbit message to be sent as response based on the given result object.- Overrides:
buildMessagein classAbstractAdaptableMessageListener- Parameters:
channel- the Rabbit Channel to operate onresult- the content of the message, as returned from the listener methodgenericType- the generic type of the result.- Returns:
- the Rabbit
Message(nevernull) - See Also:
-