Class RabbitMessagingTemplate

    • Method Detail

      • setRabbitTemplate

        public void setRabbitTemplate​(RabbitTemplate rabbitTemplate)
        Set the RabbitTemplate to use.
        Parameters:
        rabbitTemplate - the template.
      • setUseTemplateDefaultReceiveQueue

        public void setUseTemplateDefaultReceiveQueue​(boolean useTemplateDefaultReceiveQueue)
        When true, use the underlying RabbitTemplate's defaultReceiveQueue property (if configured) for receive only methods instead of the defaultDestination configured in this template. Set this to true to use the template's queue instead. Default false, but will be true in a future release.
        Parameters:
        useTemplateDefaultReceiveQueue - true to use the template's queue.
        Since:
        2.2.22
      • send

        public void send​(java.lang.String exchange,
                         java.lang.String routingKey,
                         Message<?> message)
                  throws MessagingException
        Description copied from interface: RabbitMessageOperations
        Send a message to a specific exchange with a specific routing key.
        Specified by:
        send in interface RabbitMessageOperations
        Parameters:
        exchange - the name of the exchange
        routingKey - the routing key
        message - the message to send
        Throws:
        MessagingException - a messaging exception.
      • convertAndSend

        public void convertAndSend​(java.lang.String exchange,
                                   java.lang.String routingKey,
                                   java.lang.Object payload)
                            throws MessagingException
        Description copied from interface: RabbitMessageOperations
        Convert the given Object to serialized form, possibly using a MessageConverter, wrap it as a message and send it to a specific exchange with a specific routing key.
        Specified by:
        convertAndSend in interface RabbitMessageOperations
        Parameters:
        exchange - the name of the exchange
        routingKey - the routing key
        payload - the Object to use as payload
        Throws:
        MessagingException - a messaging exception.
      • convertAndSend

        public void convertAndSend​(java.lang.String exchange,
                                   java.lang.String routingKey,
                                   java.lang.Object payload,
                                   @Nullable
                                   java.util.Map<java.lang.String,​java.lang.Object> headers)
                            throws MessagingException
        Description copied from interface: RabbitMessageOperations
        Convert the given Object to serialized form, possibly using a MessageConverter, wrap it as a message with the given headers and send it to a specific exchange with a specific routing key.
        Specified by:
        convertAndSend in interface RabbitMessageOperations
        Parameters:
        exchange - the name of the exchange
        routingKey - the routing key
        payload - the Object to use as payload
        headers - headers for the message to send
        Throws:
        MessagingException - a messaging exception.
      • convertAndSend

        public void convertAndSend​(java.lang.String exchange,
                                   java.lang.String routingKey,
                                   java.lang.Object payload,
                                   @Nullable
                                   MessagePostProcessor postProcessor)
                            throws MessagingException
        Description copied from interface: RabbitMessageOperations
        Convert the given Object to serialized form, possibly using a MessageConverter, wrap it as a message, apply the given post processor, and send the resulting message to a specific exchange with a specific routing key.
        Specified by:
        convertAndSend in interface RabbitMessageOperations
        Parameters:
        exchange - the name of the exchange
        routingKey - the routing key
        payload - the Object to use as payload
        postProcessor - the post processor to apply to the message
        Throws:
        MessagingException - a messaging exception.
      • convertAndSend

        public void convertAndSend​(java.lang.String exchange,
                                   java.lang.String routingKey,
                                   java.lang.Object payload,
                                   @Nullable
                                   java.util.Map<java.lang.String,​java.lang.Object> headers,
                                   @Nullable
                                   MessagePostProcessor postProcessor)
                            throws MessagingException
        Description copied from interface: RabbitMessageOperations
        Convert the given Object to serialized form, possibly using a MessageConverter, wrap it as a message with the given headers, apply the given post processor, and send the resulting message to a specific exchange with a specific routing key.
        Specified by:
        convertAndSend in interface RabbitMessageOperations
        Parameters:
        exchange - the name of the exchange
        routingKey - the routing key
        payload - the Object to use as payload
        headers - headers for the message to send
        postProcessor - the post processor to apply to the message
        Throws:
        MessagingException - a messaging exception.
      • sendAndReceive

        @Nullable
        public Message<?> sendAndReceive​(java.lang.String exchange,
                                         java.lang.String routingKey,
                                         Message<?> requestMessage)
                                  throws MessagingException
        Description copied from interface: RabbitMessageOperations
        Send a request message to a specific exchange with a specific routing key and wait for the reply.
        Specified by:
        sendAndReceive in interface RabbitMessageOperations
        Parameters:
        exchange - the name of the exchange
        routingKey - the routing key
        requestMessage - the message to send
        Returns:
        the reply, possibly null if the message could not be received, for example due to a timeout
        Throws:
        MessagingException - a messaging exception.
      • convertSendAndReceive

        @Nullable
        public <T> T convertSendAndReceive​(java.lang.String exchange,
                                           java.lang.String routingKey,
                                           java.lang.Object request,
                                           java.lang.Class<T> targetClass)
                                    throws MessagingException
        Description copied from interface: RabbitMessageOperations
        Convert the given request Object to serialized form, possibly using a MessageConverter, send it as a Message to a specific exchange with a specific routing key, receive the reply and convert its body of the specified target class.
        Specified by:
        convertSendAndReceive in interface RabbitMessageOperations
        Type Parameters:
        T - return type
        Parameters:
        exchange - the name of the exchange
        routingKey - the routing key
        request - payload for the request message to send
        targetClass - the target type to convert the payload of the reply to
        Returns:
        the payload of the reply message, possibly null if the message could not be received, for example due to a timeout
        Throws:
        MessagingException - a messaging exception.
      • convertSendAndReceive

        @Nullable
        public <T> T convertSendAndReceive​(java.lang.String exchange,
                                           java.lang.String routingKey,
                                           java.lang.Object request,
                                           @Nullable
                                           java.util.Map<java.lang.String,​java.lang.Object> headers,
                                           java.lang.Class<T> targetClass)
                                    throws MessagingException
        Description copied from interface: RabbitMessageOperations
        Convert the given request Object to serialized form, possibly using a MessageConverter, send it as a Message with the given headers, to a specific exchange with a specific routing key, receive the reply and convert its body of the specified target class.
        Specified by:
        convertSendAndReceive in interface RabbitMessageOperations
        Type Parameters:
        T - return type
        Parameters:
        exchange - the name of the exchange
        routingKey - the routing key
        request - payload for the request message to send
        headers - headers for the request message to send
        targetClass - the target type to convert the payload of the reply to
        Returns:
        the payload of the reply message, possibly null if the message could not be received, for example due to a timeout
        Throws:
        MessagingException - a messaging exception.
      • convertSendAndReceive

        @Nullable
        public <T> T convertSendAndReceive​(java.lang.String exchange,
                                           java.lang.String routingKey,
                                           java.lang.Object request,
                                           java.lang.Class<T> targetClass,
                                           @Nullable
                                           MessagePostProcessor requestPostProcessor)
                                    throws MessagingException
        Description copied from interface: RabbitMessageOperations
        Convert the given request Object to serialized form, possibly using a MessageConverter, apply the given post processor and send the resulting Message to a specific exchange with a specific routing key, receive the reply and convert its body of the given target class.
        Specified by:
        convertSendAndReceive in interface RabbitMessageOperations
        Type Parameters:
        T - return type
        Parameters:
        exchange - the name of the exchange
        routingKey - the routing key
        request - payload for the request message to send
        targetClass - the target type to convert the payload of the reply to
        requestPostProcessor - post process to apply to the request message
        Returns:
        the payload of the reply message, possibly null if the message could not be received, for example due to a timeout
        Throws:
        MessagingException - a messaging exception.
      • convertSendAndReceive

        @Nullable
        public <T> T convertSendAndReceive​(java.lang.String exchange,
                                           java.lang.String routingKey,
                                           java.lang.Object request,
                                           @Nullable
                                           java.util.Map<java.lang.String,​java.lang.Object> headers,
                                           java.lang.Class<T> targetClass,
                                           @Nullable
                                           MessagePostProcessor requestPostProcessor)
                                    throws MessagingException
        Description copied from interface: RabbitMessageOperations
        Convert the given request Object to serialized form, possibly using a MessageConverter, wrap it as a message with the given headers, apply the given post processor and send the resulting Message to a specific exchange with a specific routing key,, receive the reply and convert its body of the given target class.
        Specified by:
        convertSendAndReceive in interface RabbitMessageOperations
        Type Parameters:
        T - return type
        Parameters:
        exchange - the name of the exchange
        routingKey - the routing key
        request - payload for the request message to send
        headers - headers for the message to send
        targetClass - the target type to convert the payload of the reply to
        requestPostProcessor - post process to apply to the request message
        Returns:
        the payload of the reply message, possibly null if the message could not be received, for example due to a timeout
        Throws:
        MessagingException - a messaging exception.
      • doSend

        protected void doSend​(java.lang.String exchange,
                              java.lang.String routingKey,
                              Message<?> message)
      • doSendAndReceive

        @Nullable
        protected Message<?> doSendAndReceive​(java.lang.String exchange,
                                              java.lang.String routingKey,
                                              Message<?> requestMessage)
      • convertAmqpException

        protected MessagingException convertAmqpException​(java.lang.RuntimeException ex)