Class MethodAmqpListenerEndpoint
java.lang.Object
org.springframework.amqp.client.config.AbstractAmqpListenerEndpoint
org.springframework.amqp.client.config.MethodAmqpListenerEndpoint
- All Implemented Interfaces:
AmqpListenerEndpoint
The
AbstractAmqpListenerEndpoint implementation for POJO method invocation listener.
Usually, instances of this class are created and handled by the framework.
The setMessageHandlerMethodFactory(MessageHandlerMethodFactory) and setBeanFactory(BeanFactory)
must be provided before calling getMessageListener().
If other options have to be propagated to the AmqpMessagingListenerAdapter,
they have to be provided prior to getMessageListener() call.
If this class is configured by the framework, any not provided options will be populated
with default values from the MethodAmqpMessageListenerContainerFactory (if any).
- Since:
- 4.1
- Author:
- Artem Bilan
-
Constructor Summary
ConstructorsConstructorDescriptionMethodAmqpListenerEndpoint(Object bean, Method method, String... addresses) Create an instance for the method to invoke on the provided bean. -
Method Summary
Modifier and TypeMethodDescriptionprotected @Nullable AmqpListenerErrorHandlerprotected @Nullable AmqpHeaderMapperprotected @Nullable MessageConverterReturn the message listener to be used in the target listener container bean.protected @Nullable Stringprotected @Nullable ReplyPostProcessorprotected booleanprotected booleanvoidsetBeanFactory(BeanFactory beanFactory) Provide aBeanFactoryto use for resolving expressions in the listener method.voidsetDefaultRequeueRejected(boolean defaultRequeueRejected) Set the default behavior for messages rejection, for example, when the listener throws an exception.voidsetErrorHandler(AmqpListenerErrorHandler errorHandler) Set theAmqpListenerErrorHandlerto invoke if the listener method throws an exception.voidsetHeaderMapper(AmqpHeaderMapper headerMapper) Set theAmqpHeaderMapperimplementation to use to map the standard AMQP headers.voidsetMessageConverter(MessageConverter messageConverter) Set the converter to convert incoming messages to listener method arguments, and objects returned from listener methods for response messages.voidsetMessageHandlerMethodFactory(MessageHandlerMethodFactory messageHandlerMethodFactory) Set theMessageHandlerMethodFactoryto build anInvocableHandlerMethodfor the listener method.voidsetReplyContentType(String replyContentType) Set the reply content type.voidsetReplyPostProcessor(ReplyPostProcessor replyPostProcessor) Set aReplyPostProcessorto post process a response message before it is sent.voidsetReturnExceptions(boolean returnExceptions) Set whether exceptions thrown by the listener should be returned as a response message body to the sender using the normalreplyTo/@SendTosemantics.Methods inherited from class AbstractAmqpListenerEndpoint
getAddresses, getAdviceChain, getAutoAccept, getAutoStartup, getConcurrency, getGracefulShutdownPeriod, getId, getInitialCredits, getReceiveTimeout, getTaskExecutor, setAdviceChain, setAutoAccept, setAutoStartup, setConcurrency, setGracefulShutdownPeriod, setId, setInitialCredits, setReceiveTimeout, setTaskExecutor
-
Constructor Details
-
MethodAmqpListenerEndpoint
Create an instance for the method to invoke on the provided bean. Theaddressesare propagated to theAmqpMessageListenerContainer.- Parameters:
bean- the bean to invoke the method on.method- the method to invoke.addresses- the addresses to listen to.
-
-
Method Details
-
setMessageHandlerMethodFactory
Set theMessageHandlerMethodFactoryto build anInvocableHandlerMethodfor the listener method. Must be provided before callinggetMessageListener(). Usually provided by the framework.- Parameters:
messageHandlerMethodFactory- the factory to use.
-
setDefaultRequeueRejected
public void setDefaultRequeueRejected(boolean defaultRequeueRejected) Set the default behavior for messages rejection, for example, when the listener throws an exception. Whentrue(default), messages will be requeued, otherwise - rejected. Setting tofalsecauses all rejections to not be requeued. When set totrue, the default can be overridden by the listener throwing anAmqpRejectAndDontRequeueException.- Parameters:
defaultRequeueRejected-falseto reject messages by default.- See Also:
-
isDefaultRequeueRejected
protected boolean isDefaultRequeueRejected() -
setReturnExceptions
public void setReturnExceptions(boolean returnExceptions) Set whether exceptions thrown by the listener should be returned as a response message body to the sender using the normalreplyTo/@SendTosemantics.- Parameters:
returnExceptions- true to return exceptions.- See Also:
-
isReturnExceptions
protected boolean isReturnExceptions() -
setReplyPostProcessor
Set aReplyPostProcessorto post process a response message before it is sent.- Parameters:
replyPostProcessor- the post-processor.- See Also:
-
getReplyPostProcessor
-
setErrorHandler
Set theAmqpListenerErrorHandlerto invoke if the listener method throws an exception.- Parameters:
errorHandler- the error handler.- See Also:
-
getErrorHandler
-
setReplyContentType
Set the reply content type. Overrides the one populated by a message converter.- Parameters:
replyContentType- the content type.- See Also:
-
getReplyContentType
-
setHeaderMapper
Set theAmqpHeaderMapperimplementation to use to map the standard AMQP headers.- Parameters:
headerMapper- theAmqpHeaderMapperinstance.- See Also:
-
getHeaderMapper
-
setMessageConverter
Set the converter to convert incoming messages to listener method arguments, and objects returned from listener methods for response messages.- Parameters:
messageConverter- The message converter.- See Also:
-
getMessageConverter
-
setBeanFactory
Provide aBeanFactoryto use for resolving expressions in the listener method. Usually populated by the framework.- Parameters:
beanFactory- theBeanFactoryto use.
-
getMessageListener
Description copied from interface:AmqpListenerEndpointReturn the message listener to be used in the target listener container bean.- Returns:
- the message listener.
-