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
public class MessagingMessageListenerAdapter extends AbstractAdaptableMessageListener
AMessageListeneradapter that invokes a configurableHandlerAdapter.Wraps the incoming
AMQP Messageto Spring'sMessageabstraction, copying the standard headers using a configurableAmqpHeaderMapper.The original
Messageand theChannelare 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 Classes Modifier and Type Class Description protected classMessagingMessageListenerAdapter.MessagingMessageConverterAdapterDelegates 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
Constructors Modifier Constructor Description MessagingMessageListenerAdapter()MessagingMessageListenerAdapter(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected 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 HandlerAdaptergetHandlerAdapter()protected MessagingMessageConvertergetMessagingMessageConverter()protected voidinvokeHandlerAndProcessResult(Message amqpMessage, com.rabbitmq.client.Channel channel, Message<?> message)booleanisAsyncReplies()Return true if this listener is request/reply and the replies are async.voidonMessage(Message amqpMessage, com.rabbitmq.client.Channel channel)Callback 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, setRetryTemplate
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener
onMessage, onMessageBatch
-
Methods inherited from interface org.springframework.amqp.core.MessageListener
onMessageBatch
-
-
-
-
Constructor Detail
-
MessagingMessageListenerAdapter
public 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 Detail
-
setHandlerAdapter
public void setHandlerAdapter(HandlerAdapter handlerAdapter)
Set theHandlerAdapterto use to invoke the method processing an incomingMessage.- Parameters:
handlerAdapter-HandlerAdapterinstance.
-
getHandlerAdapter
protected HandlerAdapter 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
public void setHeaderMapper(AmqpHeaderMapper headerMapper)
Set theAmqpHeaderMapperimplementation to use to map the standard AMQP headers. By default, aSimpleAmqpHeaderMapperis used.- Parameters:
headerMapper- theAmqpHeaderMapperinstance.- See Also:
SimpleAmqpHeaderMapper
-
getMessagingMessageConverter
protected final MessagingMessageConverter getMessagingMessageConverter()
- Returns:
- the
MessagingMessageConverterfor this listener, being able to convertMessage.
-
setMessageConverter
public void setMessageConverter(MessageConverter messageConverter)
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
public void onMessage(Message amqpMessage, com.rabbitmq.client.Channel channel) throws Exception
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
-
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:
setMessageConverter(org.springframework.amqp.support.converter.MessageConverter)
-
-