Interface AmqpTemplate

    • Method Detail

      • send

        void send​(Message message)
           throws AmqpException
        Send a message to a default exchange with a default routing key.
        Parameters:
        message - a message to send
        Throws:
        AmqpException - if there is a problem
      • send

        void send​(java.lang.String routingKey,
                  Message message)
           throws AmqpException
        Send a message to a default exchange with a specific routing key.
        Parameters:
        routingKey - the routing key
        message - a message to send
        Throws:
        AmqpException - if there is a problem
      • send

        void send​(java.lang.String exchange,
                  java.lang.String routingKey,
                  Message message)
           throws AmqpException
        Send a message to a specific exchange with a specific routing key.
        Parameters:
        exchange - the name of the exchange
        routingKey - the routing key
        message - a message to send
        Throws:
        AmqpException - if there is a problem
      • convertAndSend

        void convertAndSend​(java.lang.Object message)
                     throws AmqpException
        Convert a Java object to an Amqp Message and send it to a default exchange with a default routing key.
        Parameters:
        message - a message to send
        Throws:
        AmqpException - if there is a problem
      • convertAndSend

        void convertAndSend​(java.lang.String routingKey,
                            java.lang.Object message)
                     throws AmqpException
        Convert a Java object to an Amqp Message and send it to a default exchange with a specific routing key.
        Parameters:
        routingKey - the routing key
        message - a message to send
        Throws:
        AmqpException - if there is a problem
      • convertAndSend

        void convertAndSend​(java.lang.String exchange,
                            java.lang.String routingKey,
                            java.lang.Object message)
                     throws AmqpException
        Convert a Java object to an Amqp Message and send it to a specific exchange with a specific routing key.
        Parameters:
        exchange - the name of the exchange
        routingKey - the routing key
        message - a message to send
        Throws:
        AmqpException - if there is a problem
      • convertAndSend

        void convertAndSend​(java.lang.Object message,
                            MessagePostProcessor messagePostProcessor)
                     throws AmqpException
        Convert a Java object to an Amqp Message and send it to a default exchange with a default routing key.
        Parameters:
        message - a message to send
        messagePostProcessor - a processor to apply to the message before it is sent
        Throws:
        AmqpException - if there is a problem
      • convertAndSend

        void convertAndSend​(java.lang.String routingKey,
                            java.lang.Object message,
                            MessagePostProcessor messagePostProcessor)
                     throws AmqpException
        Convert a Java object to an Amqp Message and send it to a default exchange with a specific routing key.
        Parameters:
        routingKey - the routing key
        message - a message to send
        messagePostProcessor - a processor to apply to the message before it is sent
        Throws:
        AmqpException - if there is a problem
      • convertAndSend

        void convertAndSend​(java.lang.String exchange,
                            java.lang.String routingKey,
                            java.lang.Object message,
                            MessagePostProcessor messagePostProcessor)
                     throws AmqpException
        Convert a Java object to an Amqp Message and send it to a specific exchange with a specific routing key.
        Parameters:
        exchange - the name of the exchange
        routingKey - the routing key
        message - a message to send
        messagePostProcessor - a processor to apply to the message before it is sent
        Throws:
        AmqpException - if there is a problem
      • receive

        @Nullable
        Message receive()
                 throws AmqpException
        Receive a message if there is one from a default queue. Returns immediately, possibly with a null value.
        Returns:
        a message or null if there is none waiting
        Throws:
        AmqpException - if there is a problem
      • receive

        @Nullable
        Message receive​(java.lang.String queueName)
                 throws AmqpException
        Receive a message if there is one from a specific queue. Returns immediately, possibly with a null value.
        Parameters:
        queueName - the name of the queue to poll
        Returns:
        a message or null if there is none waiting
        Throws:
        AmqpException - if there is a problem
      • receive

        @Nullable
        Message receive​(long timeoutMillis)
                 throws AmqpException
        Receive a message from a default queue, waiting up to the specified wait time if necessary for a message to become available.
        Parameters:
        timeoutMillis - how long to wait before giving up. Zero value means the method will return null immediately if there is no message available. Negative value makes method wait for a message indefinitely.
        Returns:
        a message or null if the time expires
        Throws:
        AmqpException - if there is a problem
        Since:
        1.6
      • receive

        @Nullable
        Message receive​(java.lang.String queueName,
                        long timeoutMillis)
                 throws AmqpException
        Receive a message from a specific queue, waiting up to the specified wait time if necessary for a message to become available.
        Parameters:
        queueName - the queue to receive from
        timeoutMillis - how long to wait before giving up. Zero value means the method will return null immediately if there is no message available. Negative value makes method wait for a message indefinitely.
        Returns:
        a message or null if the time expires
        Throws:
        AmqpException - if there is a problem
        Since:
        1.6
      • receiveAndConvert

        @Nullable
        java.lang.Object receiveAndConvert()
                                    throws AmqpException
        Receive a message if there is one from a default queue and convert it to a Java object. Returns immediately, possibly with a null value.
        Returns:
        a message or null if there is none waiting
        Throws:
        AmqpException - if there is a problem
      • receiveAndConvert

        @Nullable
        java.lang.Object receiveAndConvert​(java.lang.String queueName)
                                    throws AmqpException
        Receive a message if there is one from a specific queue and convert it to a Java object. Returns immediately, possibly with a null value.
        Parameters:
        queueName - the name of the queue to poll
        Returns:
        a message or null if there is none waiting
        Throws:
        AmqpException - if there is a problem
      • receiveAndConvert

        @Nullable
        java.lang.Object receiveAndConvert​(long timeoutMillis)
                                    throws AmqpException
        Receive a message if there is one from a default queue and convert it to a Java object. Wait up to the specified wait time if necessary for a message to become available.
        Parameters:
        timeoutMillis - how long to wait before giving up. Zero value means the method will return null immediately if there is no message available. Negative value makes method wait for a message indefinitely.
        Returns:
        a message or null if the time expires
        Throws:
        AmqpException - if there is a problem
        Since:
        1.6
      • receiveAndConvert

        @Nullable
        java.lang.Object receiveAndConvert​(java.lang.String queueName,
                                           long timeoutMillis)
                                    throws AmqpException
        Receive a message if there is one from a specific queue and convert it to a Java object. Wait up to the specified wait time if necessary for a message to become available.
        Parameters:
        queueName - the name of the queue to poll
        timeoutMillis - how long to wait before giving up. Zero value means the method will return null immediately if there is no message available. Negative value makes method wait for a message indefinitely.
        Returns:
        a message or null if the time expires
        Throws:
        AmqpException - if there is a problem
        Since:
        1.6
      • receiveAndConvert

        @Nullable
        <T> T receiveAndConvert​(ParameterizedTypeReference<T> type)
                         throws AmqpException
        Receive a message if there is one from a default queue and convert it to a Java object. Returns immediately, possibly with a null value. Requires a SmartMessageConverter.
        Type Parameters:
        T - the type.
        Parameters:
        type - the type to convert to.
        Returns:
        a message or null if there is none waiting.
        Throws:
        AmqpException - if there is a problem.
        Since:
        2.0
      • receiveAndConvert

        @Nullable
        <T> T receiveAndConvert​(java.lang.String queueName,
                                ParameterizedTypeReference<T> type)
                         throws AmqpException
        Receive a message if there is one from a specific queue and convert it to a Java object. Returns immediately, possibly with a null value. Requires a SmartMessageConverter.
        Type Parameters:
        T - the type.
        Parameters:
        queueName - the name of the queue to poll
        type - the type to convert to.
        Returns:
        a message or null if there is none waiting
        Throws:
        AmqpException - if there is a problem
        Since:
        2.0
      • receiveAndConvert

        @Nullable
        <T> T receiveAndConvert​(long timeoutMillis,
                                ParameterizedTypeReference<T> type)
                         throws AmqpException
        Receive a message if there is one from a default queue and convert it to a Java object. Wait up to the specified wait time if necessary for a message to become available. Requires a SmartMessageConverter.
        Type Parameters:
        T - the type.
        Parameters:
        timeoutMillis - how long to wait before giving up. Zero value means the method will return null immediately if there is no message available. Negative value makes method wait for a message indefinitely.
        type - the type to convert to.
        Returns:
        a message or null if the time expires
        Throws:
        AmqpException - if there is a problem
        Since:
        2.0
      • receiveAndConvert

        @Nullable
        <T> T receiveAndConvert​(java.lang.String queueName,
                                long timeoutMillis,
                                ParameterizedTypeReference<T> type)
                         throws AmqpException
        Receive a message if there is one from a specific queue and convert it to a Java object. Wait up to the specified wait time if necessary for a message to become available. Requires a SmartMessageConverter.
        Type Parameters:
        T - the type.
        Parameters:
        queueName - the name of the queue to poll
        timeoutMillis - how long to wait before giving up. Zero value means the method will return null immediately if there is no message available. Negative value makes method wait for a message indefinitely.
        type - the type to convert to.
        Returns:
        a message or null if the time expires
        Throws:
        AmqpException - if there is a problem
        Since:
        2.0
      • receiveAndReply

        <R,​S> boolean receiveAndReply​(ReceiveAndReplyCallback<R,​S> callback)
                                     throws AmqpException
        Receive a message if there is one from a default queue, invoke provided ReceiveAndReplyCallback and send reply message, if the callback returns one, to the replyTo Address from MessageProperties or to default exchange and default routingKey.
        Type Parameters:
        R - The type of the request after conversion from the Message.
        S - The type of the response.
        Parameters:
        callback - a user-provided ReceiveAndReplyCallback implementation to process received message and return a reply message.
        Returns:
        true, if message was received
        Throws:
        AmqpException - if there is a problem
      • receiveAndReply

        <R,​S> boolean receiveAndReply​(java.lang.String queueName,
                                            ReceiveAndReplyCallback<R,​S> callback)
                                     throws AmqpException
        Receive a message if there is one from provided queue, invoke provided ReceiveAndReplyCallback and send reply message, if the callback returns one, to the replyTo Address from MessageProperties or to default exchange and default routingKey.
        Type Parameters:
        R - The type of the request after conversion from the Message.
        S - The type of the response.
        Parameters:
        queueName - the queue name to receive a message.
        callback - a user-provided ReceiveAndReplyCallback implementation to process received message and return a reply message.
        Returns:
        true, if message was received.
        Throws:
        AmqpException - if there is a problem.
      • receiveAndReply

        <R,​S> boolean receiveAndReply​(ReceiveAndReplyCallback<R,​S> callback,
                                            java.lang.String replyExchange,
                                            java.lang.String replyRoutingKey)
                                     throws AmqpException
        Receive a message if there is one from default queue, invoke provided ReceiveAndReplyCallback and send reply message, if the callback returns one, to the provided exchange and routingKey.
        Type Parameters:
        R - The type of the request after conversion from the Message.
        S - The type of the response.
        Parameters:
        callback - a user-provided ReceiveAndReplyCallback implementation to process received message and return a reply message.
        replyExchange - the exchange name to send reply message.
        replyRoutingKey - the routing key to send reply message.
        Returns:
        true, if message was received.
        Throws:
        AmqpException - if there is a problem.
      • receiveAndReply

        <R,​S> boolean receiveAndReply​(java.lang.String queueName,
                                            ReceiveAndReplyCallback<R,​S> callback,
                                            java.lang.String replyExchange,
                                            java.lang.String replyRoutingKey)
                                     throws AmqpException
        Receive a message if there is one from provided queue, invoke provided ReceiveAndReplyCallback and send reply message, if the callback returns one, to the provided exchange and routingKey.
        Type Parameters:
        R - The type of the request after conversion from the Message.
        S - The type of the response.
        Parameters:
        queueName - the queue name to receive a message.
        callback - a user-provided ReceiveAndReplyCallback implementation to process received message and return a reply message.
        replyExchange - the exchange name to send reply message.
        replyRoutingKey - the routing key to send reply message.
        Returns:
        true, if message was received
        Throws:
        AmqpException - if there is a problem
      • receiveAndReply

        <R,​S> boolean receiveAndReply​(ReceiveAndReplyCallback<R,​S> callback,
                                            ReplyToAddressCallback<S> replyToAddressCallback)
                                     throws AmqpException
        Receive a message if there is one from a default queue, invoke provided ReceiveAndReplyCallback and send reply message, if the callback returns one, to the replyTo Address from result of ReplyToAddressCallback.
        Type Parameters:
        R - The type of the request after conversion from the Message.
        S - The type of the response.
        Parameters:
        callback - a user-provided ReceiveAndReplyCallback implementation to process received message and return a reply message.
        replyToAddressCallback - the callback to determine replyTo address at runtime.
        Returns:
        true, if message was received.
        Throws:
        AmqpException - if there is a problem.
      • receiveAndReply

        <R,​S> boolean receiveAndReply​(java.lang.String queueName,
                                            ReceiveAndReplyCallback<R,​S> callback,
                                            ReplyToAddressCallback<S> replyToAddressCallback)
                                     throws AmqpException
        Receive a message if there is one from provided queue, invoke provided ReceiveAndReplyCallback and send reply message, if the callback returns one, to the replyTo Address from result of ReplyToAddressCallback.
        Type Parameters:
        R - The type of the request after conversion from the Message.
        S - The type of the response.
        Parameters:
        queueName - the queue name to receive a message.
        callback - a user-provided ReceiveAndReplyCallback implementation to process received message and return a reply message.
        replyToAddressCallback - the callback to determine replyTo address at runtime.
        Returns:
        true, if message was received
        Throws:
        AmqpException - if there is a problem
      • sendAndReceive

        @Nullable
        Message sendAndReceive​(Message message)
                        throws AmqpException
        Basic RPC pattern. Send a message to a default exchange with a default routing key and attempt to receive a response. Implementations will normally set the reply-to header to an exclusive queue and wait up for some time limited by a timeout.
        Parameters:
        message - a message to send
        Returns:
        the response if there is one
        Throws:
        AmqpException - if there is a problem
      • sendAndReceive

        @Nullable
        Message sendAndReceive​(java.lang.String routingKey,
                               Message message)
                        throws AmqpException
        Basic RPC pattern. Send a message to a default exchange with a specific routing key and attempt to receive a response. Implementations will normally set the reply-to header to an exclusive queue and wait up for some time limited by a timeout.
        Parameters:
        routingKey - the routing key
        message - a message to send
        Returns:
        the response if there is one
        Throws:
        AmqpException - if there is a problem
      • sendAndReceive

        @Nullable
        Message sendAndReceive​(java.lang.String exchange,
                               java.lang.String routingKey,
                               Message message)
                        throws AmqpException
        Basic RPC pattern. Send a message to a specific exchange with a specific routing key and attempt to receive a response. Implementations will normally set the reply-to header to an exclusive queue and wait up for some time limited by a timeout.
        Parameters:
        exchange - the name of the exchange
        routingKey - the routing key
        message - a message to send
        Returns:
        the response if there is one
        Throws:
        AmqpException - if there is a problem
      • convertSendAndReceive

        @Nullable
        java.lang.Object convertSendAndReceive​(java.lang.Object message)
                                        throws AmqpException
        Basic RPC pattern with conversion. Send a Java object converted to a message to a default exchange with a default routing key and attempt to receive a response, converting that to a Java object. Implementations will normally set the reply-to header to an exclusive queue and wait up for some time limited by a timeout.
        Parameters:
        message - a message to send
        Returns:
        the response if there is one
        Throws:
        AmqpException - if there is a problem
      • convertSendAndReceive

        @Nullable
        java.lang.Object convertSendAndReceive​(java.lang.String routingKey,
                                               java.lang.Object message)
                                        throws AmqpException
        Basic RPC pattern with conversion. Send a Java object converted to a message to a default exchange with a specific routing key and attempt to receive a response, converting that to a Java object. Implementations will normally set the reply-to header to an exclusive queue and wait up for some time limited by a timeout.
        Parameters:
        routingKey - the routing key
        message - a message to send
        Returns:
        the response if there is one
        Throws:
        AmqpException - if there is a problem
      • convertSendAndReceive

        @Nullable
        java.lang.Object convertSendAndReceive​(java.lang.String exchange,
                                               java.lang.String routingKey,
                                               java.lang.Object message)
                                        throws AmqpException
        Basic RPC pattern with conversion. Send a Java object converted to a message to a specific exchange with a specific routing key and attempt to receive a response, converting that to a Java object. Implementations will normally set the reply-to header to an exclusive queue and wait up for some time limited by a timeout.
        Parameters:
        exchange - the name of the exchange
        routingKey - the routing key
        message - a message to send
        Returns:
        the response if there is one
        Throws:
        AmqpException - if there is a problem
      • convertSendAndReceive

        @Nullable
        java.lang.Object convertSendAndReceive​(java.lang.Object message,
                                               MessagePostProcessor messagePostProcessor)
                                        throws AmqpException
        Basic RPC pattern with conversion. Send a Java object converted to a message to a default exchange with a default routing key and attempt to receive a response, converting that to a Java object. Implementations will normally set the reply-to header to an exclusive queue and wait up for some time limited by a timeout.
        Parameters:
        message - a message to send
        messagePostProcessor - a processor to apply to the message before it is sent
        Returns:
        the response if there is one
        Throws:
        AmqpException - if there is a problem
      • convertSendAndReceive

        @Nullable
        java.lang.Object convertSendAndReceive​(java.lang.String routingKey,
                                               java.lang.Object message,
                                               MessagePostProcessor messagePostProcessor)
                                        throws AmqpException
        Basic RPC pattern with conversion. Send a Java object converted to a message to a default exchange with a specific routing key and attempt to receive a response, converting that to a Java object. Implementations will normally set the reply-to header to an exclusive queue and wait up for some time limited by a timeout.
        Parameters:
        routingKey - the routing key
        message - a message to send
        messagePostProcessor - a processor to apply to the message before it is sent
        Returns:
        the response if there is one
        Throws:
        AmqpException - if there is a problem
      • convertSendAndReceive

        @Nullable
        java.lang.Object convertSendAndReceive​(java.lang.String exchange,
                                               java.lang.String routingKey,
                                               java.lang.Object message,
                                               MessagePostProcessor messagePostProcessor)
                                        throws AmqpException
        Basic RPC pattern with conversion. Send a Java object converted to a message to a specific exchange with a specific routing key and attempt to receive a response, converting that to a Java object. Implementations will normally set the reply-to header to an exclusive queue and wait up for some time limited by a timeout.
        Parameters:
        exchange - the name of the exchange
        routingKey - the routing key
        message - a message to send
        messagePostProcessor - a processor to apply to the message before it is sent
        Returns:
        the response if there is one
        Throws:
        AmqpException - if there is a problem
      • convertSendAndReceiveAsType

        @Nullable
        <T> T convertSendAndReceiveAsType​(java.lang.Object message,
                                          ParameterizedTypeReference<T> responseType)
                                   throws AmqpException
        Basic RPC pattern with conversion. Send a Java object converted to a message to a default exchange with a default routing key and attempt to receive a response, converting that to a Java object. Implementations will normally set the reply-to header to an exclusive queue and wait up for some time limited by a timeout. Requires a SmartMessageConverter.
        Type Parameters:
        T - the type.
        Parameters:
        message - a message to send.
        responseType - the type to convert the reply to.
        Returns:
        the response if there is one.
        Throws:
        AmqpException - if there is a problem.
        Since:
        2.0
      • convertSendAndReceiveAsType

        @Nullable
        <T> T convertSendAndReceiveAsType​(java.lang.String routingKey,
                                          java.lang.Object message,
                                          ParameterizedTypeReference<T> responseType)
                                   throws AmqpException
        Basic RPC pattern with conversion. Send a Java object converted to a message to a default exchange with a specific routing key and attempt to receive a response, converting that to a Java object. Implementations will normally set the reply-to header to an exclusive queue and wait up for some time limited by a timeout. Requires a SmartMessageConverter.
        Type Parameters:
        T - the type.
        Parameters:
        routingKey - the routing key
        message - a message to send
        responseType - the type to convert the reply to.
        Returns:
        the response if there is one
        Throws:
        AmqpException - if there is a problem
        Since:
        2.0
      • convertSendAndReceiveAsType

        @Nullable
        <T> T convertSendAndReceiveAsType​(java.lang.String exchange,
                                          java.lang.String routingKey,
                                          java.lang.Object message,
                                          ParameterizedTypeReference<T> responseType)
                                   throws AmqpException
        Basic RPC pattern with conversion. Send a Java object converted to a message to a specific exchange with a specific routing key and attempt to receive a response, converting that to a Java object. Implementations will normally set the reply-to header to an exclusive queue and wait up for some time limited by a timeout. Requires a SmartMessageConverter.
        Type Parameters:
        T - the type.
        Parameters:
        exchange - the name of the exchange
        routingKey - the routing key
        message - a message to send
        responseType - the type to convert the reply to.
        Returns:
        the response if there is one
        Throws:
        AmqpException - if there is a problem
        Since:
        2.0
      • convertSendAndReceiveAsType

        @Nullable
        <T> T convertSendAndReceiveAsType​(java.lang.Object message,
                                          MessagePostProcessor messagePostProcessor,
                                          ParameterizedTypeReference<T> responseType)
                                   throws AmqpException
        Basic RPC pattern with conversion. Send a Java object converted to a message to a default exchange with a default routing key and attempt to receive a response, converting that to a Java object. Implementations will normally set the reply-to header to an exclusive queue and wait up for some time limited by a timeout. Requires a SmartMessageConverter.
        Type Parameters:
        T - the type.
        Parameters:
        message - a message to send
        messagePostProcessor - a processor to apply to the message before it is sent
        responseType - the type to convert the reply to.
        Returns:
        the response if there is one
        Throws:
        AmqpException - if there is a problem
        Since:
        2.0
      • convertSendAndReceiveAsType

        @Nullable
        <T> T convertSendAndReceiveAsType​(java.lang.String routingKey,
                                          java.lang.Object message,
                                          MessagePostProcessor messagePostProcessor,
                                          ParameterizedTypeReference<T> responseType)
                                   throws AmqpException
        Basic RPC pattern with conversion. Send a Java object converted to a message to a default exchange with a specific routing key and attempt to receive a response, converting that to a Java object. Implementations will normally set the reply-to header to an exclusive queue and wait up for some time limited by a timeout. Requires a SmartMessageConverter.
        Type Parameters:
        T - the type.
        Parameters:
        routingKey - the routing key
        message - a message to send
        messagePostProcessor - a processor to apply to the message before it is sent
        responseType - the type to convert the reply to.
        Returns:
        the response if there is one
        Throws:
        AmqpException - if there is a problem
        Since:
        2.0
      • convertSendAndReceiveAsType

        @Nullable
        <T> T convertSendAndReceiveAsType​(java.lang.String exchange,
                                          java.lang.String routingKey,
                                          java.lang.Object message,
                                          MessagePostProcessor messagePostProcessor,
                                          ParameterizedTypeReference<T> responseType)
                                   throws AmqpException
        Basic RPC pattern with conversion. Send a Java object converted to a message to a specific exchange with a specific routing key and attempt to receive a response, converting that to a Java object. Implementations will normally set the reply-to header to an exclusive queue and wait up for some time limited by a timeout. Requires a SmartMessageConverter.
        Type Parameters:
        T - the type.
        Parameters:
        exchange - the name of the exchange
        routingKey - the routing key
        message - a message to send
        messagePostProcessor - a processor to apply to the message before it is sent
        responseType - the type to convert the reply to.
        Returns:
        the response if there is one
        Throws:
        AmqpException - if there is a problem
        Since:
        2.0