Class AbstractAdaptableMessageListener

    • Field Detail

      • logger

        protected final Log logger
        Logger available to subclasses.
    • Constructor Detail

      • AbstractAdaptableMessageListener

        public AbstractAdaptableMessageListener()
    • Method Detail

      • setResponseRoutingKey

        public void setResponseRoutingKey​(String responseRoutingKey)
        Set the routing key to use when sending response messages. This will be applied in case of a request message that does not carry a "ReplyTo" property

        Response destinations are only relevant for listener methods that return result objects, which will be wrapped in a response message and sent to a response destination.

        Parameters:
        responseRoutingKey - The routing key.
      • setEncoding

        public void setEncoding​(String encoding)
        The encoding to use when inter-converting between byte arrays and Strings in message properties.
        Parameters:
        encoding - the encoding to set.
      • getEncoding

        public String getEncoding()
        The encoding to use when inter-converting between byte arrays and Strings in message properties.
        Returns:
        encoding the encoding.
      • setResponseExchange

        public void setResponseExchange​(String responseExchange)
        Set the exchange to use when sending response messages. This is only used if the exchange from the received message is null.

        Response destinations are only relevant for listener methods that return result objects, which will be wrapped in a response message and sent to a response destination.

        Parameters:
        responseExchange - The exchange.
      • setResponseAddress

        public void setResponseAddress​(String defaultReplyTo)
        Set the default replyTo address to use when sending response messages. This is only used if the replyTo from the received message is null.

        Response destinations are only relevant for listener methods that return result objects, which will be wrapped in a response message and sent to a response destination.

        It is parsed in Address so should be of the form exchange/rk.

        It can be a string surrounded by "!{...}" in which case the expression is evaluated at runtime; see the reference manual for more information.

        Parameters:
        defaultReplyTo - The replyTo address.
        Since:
        1.6
      • setMandatoryPublish

        public void setMandatoryPublish​(boolean mandatoryPublish)
      • setMessageConverter

        public void setMessageConverter​(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.

        The default converter is a SimpleMessageConverter, which is able to handle "text" content-types.

        Parameters:
        messageConverter - The message converter.
      • setBeforeSendReplyPostProcessors

        public void setBeforeSendReplyPostProcessors​(MessagePostProcessor... beforeSendReplyPostProcessors)
        Set post processors that will be applied before sending replies.
        Parameters:
        beforeSendReplyPostProcessors - the post processors.
        Since:
        2.0.3
      • setRetryTemplate

        public void setRetryTemplate​(org.springframework.retry.support.RetryTemplate retryTemplate)
        Set a RetryTemplate to use when sending replies.
        Parameters:
        retryTemplate - the template.
        Since:
        2.0.6
        See Also:
        setRecoveryCallback(RecoveryCallback)
      • setRecoveryCallback

        public void setRecoveryCallback​(org.springframework.retry.RecoveryCallback<?> recoveryCallback)
        Set a RecoveryCallback to invoke when retries are exhausted.
        Parameters:
        recoveryCallback - the recovery callback.
        Since:
        2.0.6
        See Also:
        setRetryTemplate(RetryTemplate)
      • setBeanResolver

        public void setBeanResolver​(BeanResolver beanResolver)
        Set a bean resolver for runtime SpEL expressions. Also configures the evaluation context with a standard type converter and map accessor.
        Parameters:
        beanResolver - the resolver.
        Since:
        1.6
      • getReplyContentType

        protected String getReplyContentType()
        Get the reply content type.
        Returns:
        the content type.
        Since:
        2.3
      • setReplyContentType

        public void setReplyContentType​(String replyContentType)
        Set the reply content type.
        Parameters:
        replyContentType - the content type.
        Since:
        2.3
      • isConverterWinsContentType

        protected boolean isConverterWinsContentType()
        Return whether the content type set by a converter prevails or not.
        Returns:
        false to always apply the reply content type.
        Since:
        2.3
      • setConverterWinsContentType

        public void setConverterWinsContentType​(boolean converterWinsContentType)
        Set whether the content type set by a converter prevails or not.
        Parameters:
        converterWinsContentType - false to always apply the reply content type.
        Since:
        2.3
      • getMessageConverter

        protected MessageConverter getMessageConverter()
        Return the converter that will convert incoming Rabbit messages to listener method arguments, and objects returned from listener methods back to Rabbit messages.
        Returns:
        The message converter.
      • setDefaultRequeueRejected

        public void setDefaultRequeueRejected​(boolean defaultRequeueRejected)
        Set to the value of this listener's container equivalent property. Used when rejecting from an async listener.
        Parameters:
        defaultRequeueRejected - false to not requeue.
        Since:
        2.1.8
      • extractMessage

        protected Object extractMessage​(Message message)
        Extract the message body from the given Rabbit message.
        Parameters:
        message - the Rabbit Message
        Returns:
        the content of the message, to be passed into the listener method as argument
      • doHandleResult

        protected void doHandleResult​(InvocationResult resultArg,
                                      Message request,
                                      com.rabbitmq.client.Channel channel,
                                      Object source)
      • getReceivedExchange

        protected String getReceivedExchange​(Message request)
      • 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.
        Parameters:
        channel - the Rabbit Channel to operate on.
        result - the content of the message, as returned from the listener method.
        genericType - the generic type to populate type headers.
        Returns:
        the Rabbit Message (never null).
        See Also:
        setMessageConverter(org.springframework.amqp.support.converter.MessageConverter)
      • convert

        protected Message convert​(Object result,
                                  Type genericType,
                                  MessageConverter converter)
        Convert to a message, with reply content type based on settings.
        Parameters:
        result - the result.
        genericType - the type.
        converter - the converter.
        Returns:
        the message.
        Since:
        2.3
      • postProcessResponse

        protected void postProcessResponse​(Message request,
                                           Message response)
        Post-process the given response message before it will be sent.

        The default implementation sets the response's correlation id to the request message's correlation id, if any; otherwise to the request message id.

        Parameters:
        request - the original incoming Rabbit message
        response - the outgoing Rabbit message about to be sent
      • sendResponse

        protected void sendResponse​(com.rabbitmq.client.Channel channel,
                                    Address replyTo,
                                    Message messageIn)
        Send the given response message to the given destination.
        Parameters:
        channel - the Rabbit channel to operate on
        replyTo - the Rabbit ReplyTo string to use when sending. Currently interpreted to be the routing key.
        messageIn - the Rabbit message to send
        See Also:
        postProcessResponse(Message, Message), setReplyPostProcessor(ReplyPostProcessor)
      • postProcessChannel

        protected void postProcessChannel​(com.rabbitmq.client.Channel channel,
                                          Message response)
        Post-process the given message before sending the response.

        The default implementation is empty.

        Parameters:
        channel - The channel.
        response - the outgoing Rabbit message about to be sent