Class RabbitAmqpMessageListenerAdapter
java.lang.Object
org.springframework.amqp.rabbit.listener.adapter.AbstractAdaptableMessageListener
org.springframework.amqp.rabbit.listener.adapter.MessagingMessageListenerAdapter
org.springframework.amqp.rabbitmq.client.listener.RabbitAmqpMessageListenerAdapter
- All Implemented Interfaces:
MessageListener,ChannelAwareMessageListener,RabbitAmqpMessageListener
public class RabbitAmqpMessageListenerAdapter
extends MessagingMessageListenerAdapter
implements RabbitAmqpMessageListener
A
MessagingMessageListenerAdapter extension for the RabbitAmqpMessageListener.
Provides these arguments for the MessagingMessageListenerAdapter.getHandlerAdapter() invocation:
Message- the native AMQP 1.0 message without any conversionsMessage- Spring AMQP message abstraction as conversion result from the native AMQP 1.0 messageMessage- Spring Messaging abstraction as conversion result from the Spring AMQP messageConsumer.Context- RabbitMQ AMQP client consumer settlement API.AmqpAcknowledgment- Spring AMQP acknowledgment abstraction: delegates to theConsumer.Context
This class reuses the MessagingMessageListenerAdapter as much as possible just to avoid duplication.
The Channel abstraction from AMQP Client 0.9.1 is out use and present here just for API compatibility
and to follow DRY principle.
Can be reworked eventually, when this AMQP 1.0 client won't be based on spring-rabbit dependency.
- Since:
- 4.0
- Author:
- Artem Bilan
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.amqp.rabbit.listener.adapter.MessagingMessageListenerAdapter
MessagingMessageListenerAdapter.MessagingMessageConverterAdapterNested 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.MessagingMessageListenerAdapter
errorHandler, messagingMessageConverter, returnExceptionsFields inherited from class org.springframework.amqp.rabbit.listener.adapter.AbstractAdaptableMessageListener
logger -
Constructor Summary
ConstructorsConstructorDescriptionRabbitAmqpMessageListenerAdapter(@Nullable Object bean, @Nullable Method method, boolean returnExceptions, @Nullable RabbitListenerErrorHandler errorHandler, boolean batch) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidasyncFailure(Message request, @Nullable com.rabbitmq.client.Channel channel, Throwable t, @Nullable Object source) protected voidvoidonAmqpMessage(com.rabbitmq.client.amqp.Message amqpMessage, @Nullable com.rabbitmq.client.amqp.Consumer.Context context) Process an AMQP message.voidonMessageBatch(List<Message> messages) Delivers a batch of messages.protected voidsendResponse(@Nullable com.rabbitmq.client.Channel channel, Address replyTo, Message messageIn) Send the given response message to the given destination.voidsetAfterReceivePostProcessors(Collection<MessagePostProcessor> afterReceivePostProcessors) voidsetConnectionFactory(AmqpConnectionFactory connectionFactory) Set aAmqpConnectionFactoryfor publishing replies from this adapter.Methods inherited from class org.springframework.amqp.rabbit.listener.adapter.MessagingMessageListenerAdapter
buildMessage, getHandlerAdapter, getMessagingMessageConverter, handleException, invokeHandler, invokeHandlerAndProcessResult, isAsyncReplies, onMessage, setHandlerAdapter, setHeaderMapper, setMessageConverter, toMessagingMessageMethods inherited from class org.springframework.amqp.rabbit.listener.adapter.AbstractAdaptableMessageListener
containerAckMode, convert, doHandleResult, doPublish, extractMessage, getBeforeSendReplyPostProcessors, getEncoding, getMessageConverter, getReceivedExchange, getReplyContentType, getReplyToAddress, handleListenerException, handleResult, handleResult, isConverterWinsContentType, isDefaultRequeueRejected, isManualAck, postProcessChannel, postProcessResponse, 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
containerAckMode, isAsyncReplies
-
Constructor Details
-
RabbitAmqpMessageListenerAdapter
public RabbitAmqpMessageListenerAdapter(@Nullable Object bean, @Nullable Method method, boolean returnExceptions, @Nullable RabbitListenerErrorHandler errorHandler, boolean batch)
-
-
Method Details
-
setAfterReceivePostProcessors
public void setAfterReceivePostProcessors(Collection<MessagePostProcessor> afterReceivePostProcessors) -
setConnectionFactory
Set aAmqpConnectionFactoryfor publishing replies from this adapter.- Parameters:
connectionFactory- theAmqpConnectionFactoryfor replies.
-
onAmqpMessage
public void onAmqpMessage(com.rabbitmq.client.amqp.Message amqpMessage, @Nullable com.rabbitmq.client.amqp.Consumer.Context context) Description copied from interface:RabbitAmqpMessageListenerProcess an AMQP message.- Specified by:
onAmqpMessagein interfaceRabbitAmqpMessageListener- Parameters:
amqpMessage- the message to process.context- the consumer context to settle message. Null if container is configured forautoSettle.
-
asyncFailure
protected void asyncFailure(Message request, @Nullable com.rabbitmq.client.Channel channel, Throwable t, @Nullable Object source) - Overrides:
asyncFailurein classMessagingMessageListenerAdapter
-
sendResponse
protected void sendResponse(@Nullable com.rabbitmq.client.Channel channel, Address replyTo, Message messageIn) Description copied from class:AbstractAdaptableMessageListenerSend the given response message to the given destination.- Overrides:
sendResponsein classAbstractAdaptableMessageListener- Parameters:
channel- the Rabbit channel to operate onreplyTo- the Rabbit ReplyTo string to use when sending. Currently interpreted to be the routing key.messageIn- the Rabbit message to send- See Also:
-
basicAck
- Overrides:
basicAckin classAbstractAdaptableMessageListener
-
onMessageBatch
Description copied from interface:MessageListenerDelivers a batch of messages.- Specified by:
onMessageBatchin interfaceMessageListener- Parameters:
messages- the messages.
-