Interface RabbitOperations

  • All Superinterfaces:
    org.springframework.amqp.core.AmqpTemplate, org.springframework.context.Lifecycle
    All Known Implementing Classes:
    BatchingRabbitTemplate, RabbitTemplate

    public interface RabbitOperations
    extends org.springframework.amqp.core.AmqpTemplate, org.springframework.context.Lifecycle
    Rabbit specific methods for Amqp functionality.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static interface  RabbitOperations.OperationsCallback<T>
      Callback for using the same channel for multiple RabbitTemplate operations.
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      void convertAndSend​(java.lang.Object message, org.springframework.amqp.core.MessagePostProcessor messagePostProcessor, CorrelationData correlationData)
      Convert a Java object to an Amqp Message and send it to a default exchange with a default routing key.
      void convertAndSend​(java.lang.String routingKey, java.lang.Object message, org.springframework.amqp.core.MessagePostProcessor messagePostProcessor, CorrelationData correlationData)
      Convert a Java object to an Amqp Message and send it to a default exchange with a specific routing key.
      void convertAndSend​(java.lang.String routingKey, java.lang.Object message, CorrelationData correlationData)
      Convert a Java object to an Amqp Message and send it to a default exchange with a specific routing key.
      void convertAndSend​(java.lang.String exchange, java.lang.String routingKey, java.lang.Object message, org.springframework.amqp.core.MessagePostProcessor messagePostProcessor, CorrelationData correlationData)
      Convert a Java object to an Amqp Message and send it to a specific exchange with a specific routing key.
      void convertAndSend​(java.lang.String exchange, java.lang.String routingKey, java.lang.Object message, CorrelationData correlationData)
      Convert a Java object to an Amqp Message and send it to a specific exchange with a specific routing key.
      java.lang.Object convertSendAndReceive​(java.lang.Object message, org.springframework.amqp.core.MessagePostProcessor messagePostProcessor, CorrelationData correlationData)
      Basic RPC pattern with conversion.
      java.lang.Object convertSendAndReceive​(java.lang.Object message, CorrelationData correlationData)
      Basic RPC pattern with conversion.
      java.lang.Object convertSendAndReceive​(java.lang.String routingKey, java.lang.Object message, org.springframework.amqp.core.MessagePostProcessor messagePostProcessor, CorrelationData correlationData)
      Basic RPC pattern with conversion.
      java.lang.Object convertSendAndReceive​(java.lang.String routingKey, java.lang.Object message, CorrelationData correlationData)
      Basic RPC pattern with conversion.
      java.lang.Object convertSendAndReceive​(java.lang.String exchange, java.lang.String routingKey, java.lang.Object message, org.springframework.amqp.core.MessagePostProcessor messagePostProcessor, CorrelationData correlationData)
      Basic RPC pattern with conversion.
      java.lang.Object convertSendAndReceive​(java.lang.String exchange, java.lang.String routingKey, java.lang.Object message, CorrelationData correlationData)
      Basic RPC pattern with conversion.
      <T> T convertSendAndReceiveAsType​(java.lang.Object message, org.springframework.amqp.core.MessagePostProcessor messagePostProcessor, CorrelationData correlationData, org.springframework.core.ParameterizedTypeReference<T> responseType)
      Basic RPC pattern with conversion.
      <T> T convertSendAndReceiveAsType​(java.lang.Object message, CorrelationData correlationData, org.springframework.core.ParameterizedTypeReference<T> responseType)
      Basic RPC pattern with conversion.
      <T> T convertSendAndReceiveAsType​(java.lang.String routingKey, java.lang.Object message, org.springframework.amqp.core.MessagePostProcessor messagePostProcessor, CorrelationData correlationData, org.springframework.core.ParameterizedTypeReference<T> responseType)
      Basic RPC pattern with conversion.
      <T> T convertSendAndReceiveAsType​(java.lang.String routingKey, java.lang.Object message, CorrelationData correlationData, org.springframework.core.ParameterizedTypeReference<T> responseType)
      Basic RPC pattern with conversion.
      <T> T convertSendAndReceiveAsType​(java.lang.String exchange, java.lang.String routingKey, java.lang.Object message, org.springframework.amqp.core.MessagePostProcessor messagePostProcessor, CorrelationData correlationData, org.springframework.core.ParameterizedTypeReference<T> responseType)
      Basic RPC pattern with conversion.
      default <T> T convertSendAndReceiveAsType​(java.lang.String exchange, java.lang.String routingKey, java.lang.Object message, CorrelationData correlationData, org.springframework.core.ParameterizedTypeReference<T> responseType)
      Basic RPC pattern with conversion.
      void correlationConvertAndSend​(java.lang.Object message, CorrelationData correlationData)
      Convert a Java object to an Amqp Message and send it to a default exchange with a default routing key.
      <T> T execute​(ChannelCallback<T> action)
      Execute the callback with a channel and reliably close the channel afterwards.
      ConnectionFactory getConnectionFactory()
      Return the connection factory for this operations.
      default <T> T invoke​(RabbitOperations.OperationsCallback<T> action)
      Invoke the callback and run all operations on the template argument in a dedicated thread-bound channel and reliably close the channel afterwards.
      <T> T invoke​(RabbitOperations.OperationsCallback<T> action, com.rabbitmq.client.ConfirmCallback acks, com.rabbitmq.client.ConfirmCallback nacks)
      Invoke operations on the same channel.
      default boolean isRunning()  
      void send​(java.lang.String exchange, java.lang.String routingKey, org.springframework.amqp.core.Message message, CorrelationData correlationData)
      Send a message to a specific exchange with a specific routing key.
      default void send​(java.lang.String routingKey, org.springframework.amqp.core.Message message, CorrelationData correlationData)
      Send a message to the default exchange with a specific routing key.
      default void start()  
      default void stop()  
      boolean waitForConfirms​(long timeout)
      Delegate to the underlying dedicated channel to wait for confirms.
      void waitForConfirmsOrDie​(long timeout)
      Delegate to the underlying dedicated channel to wait for confirms.
      • Methods inherited from interface org.springframework.amqp.core.AmqpTemplate

        convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceiveAsType, convertSendAndReceiveAsType, convertSendAndReceiveAsType, convertSendAndReceiveAsType, convertSendAndReceiveAsType, convertSendAndReceiveAsType, receive, receive, receive, receive, receiveAndConvert, receiveAndConvert, receiveAndConvert, receiveAndConvert, receiveAndConvert, receiveAndConvert, receiveAndConvert, receiveAndConvert, receiveAndReply, receiveAndReply, receiveAndReply, receiveAndReply, receiveAndReply, receiveAndReply, send, send, send, sendAndReceive, sendAndReceive, sendAndReceive
    • Method Detail

      • execute

        @Nullable
        <T> T execute​(ChannelCallback<T> action)
               throws org.springframework.amqp.AmqpException
        Execute the callback with a channel and reliably close the channel afterwards.
        Type Parameters:
        T - the return type.
        Parameters:
        action - the call back.
        Returns:
        the result from the ChannelCallback.doInRabbit(com.rabbitmq.client.Channel).
        Throws:
        org.springframework.amqp.AmqpException - if one occurs.
      • invoke

        @Nullable
        <T> T invoke​(RabbitOperations.OperationsCallback<T> action,
                     @Nullable
                     com.rabbitmq.client.ConfirmCallback acks,
                     @Nullable
                     com.rabbitmq.client.ConfirmCallback nacks)
        Invoke operations on the same channel. If callbacks are needed, both callbacks must be supplied.
        Type Parameters:
        T - the return type.
        Parameters:
        action - the callback.
        acks - a confirm callback for acks.
        nacks - a confirm callback for nacks.
        Returns:
        the result of the action method.
        Since:
        2.1
      • waitForConfirms

        boolean waitForConfirms​(long timeout)
                         throws org.springframework.amqp.AmqpException
        Delegate to the underlying dedicated channel to wait for confirms. The connection factory must be configured for publisher confirms and this method must be called within the scope of an invoke(OperationsCallback) operation. Requires CachingConnectionFactory#setPublisherConfirms(true).
        Parameters:
        timeout - the timeout
        Returns:
        true if acks and no nacks are received.
        Throws:
        org.springframework.amqp.AmqpException - if one occurs.
        Since:
        2.0
        See Also:
        Channel.waitForConfirms(long)
      • waitForConfirmsOrDie

        void waitForConfirmsOrDie​(long timeout)
                           throws org.springframework.amqp.AmqpException
        Delegate to the underlying dedicated channel to wait for confirms. The connection factory must be configured for publisher confirms and this method must be called within the scope of an invoke(OperationsCallback) operation. Requires CachingConnectionFactory#setPublisherConfirms(true).
        Parameters:
        timeout - the timeout
        Throws:
        org.springframework.amqp.AmqpException - if one occurs.
        Since:
        2.0
        See Also:
        Channel.waitForConfirmsOrDie(long)
      • getConnectionFactory

        ConnectionFactory getConnectionFactory()
        Return the connection factory for this operations.
        Returns:
        the connection factory.
        Since:
        2.0
      • send

        default void send​(java.lang.String routingKey,
                          org.springframework.amqp.core.Message message,
                          CorrelationData correlationData)
                   throws org.springframework.amqp.AmqpException
        Send a message to the default exchange with a specific routing key.
        Parameters:
        routingKey - the routing key
        message - a message to send
        correlationData - data to correlate publisher confirms.
        Throws:
        org.springframework.amqp.AmqpException - if there is a problem
        Since:
        2.3
      • send

        void send​(java.lang.String exchange,
                  java.lang.String routingKey,
                  org.springframework.amqp.core.Message message,
                  CorrelationData correlationData)
           throws org.springframework.amqp.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
        correlationData - data to correlate publisher confirms.
        Throws:
        org.springframework.amqp.AmqpException - if there is a problem
      • correlationConvertAndSend

        void correlationConvertAndSend​(java.lang.Object message,
                                       CorrelationData correlationData)
                                throws org.springframework.amqp.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
        correlationData - data to correlate publisher confirms.
        Throws:
        org.springframework.amqp.AmqpException - if there is a problem
      • convertAndSend

        void convertAndSend​(java.lang.String routingKey,
                            java.lang.Object message,
                            CorrelationData correlationData)
                     throws org.springframework.amqp.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
        correlationData - data to correlate publisher confirms.
        Throws:
        org.springframework.amqp.AmqpException - if there is a problem
      • convertAndSend

        void convertAndSend​(java.lang.String exchange,
                            java.lang.String routingKey,
                            java.lang.Object message,
                            CorrelationData correlationData)
                     throws org.springframework.amqp.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
        correlationData - data to correlate publisher confirms.
        Throws:
        org.springframework.amqp.AmqpException - if there is a problem
      • convertAndSend

        void convertAndSend​(java.lang.Object message,
                            org.springframework.amqp.core.MessagePostProcessor messagePostProcessor,
                            CorrelationData correlationData)
                     throws org.springframework.amqp.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
        correlationData - data to correlate publisher confirms.
        Throws:
        org.springframework.amqp.AmqpException - if there is a problem
      • convertAndSend

        void convertAndSend​(java.lang.String routingKey,
                            java.lang.Object message,
                            org.springframework.amqp.core.MessagePostProcessor messagePostProcessor,
                            CorrelationData correlationData)
                     throws org.springframework.amqp.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
        correlationData - data to correlate publisher confirms.
        Throws:
        org.springframework.amqp.AmqpException - if there is a problem
      • convertAndSend

        void convertAndSend​(java.lang.String exchange,
                            java.lang.String routingKey,
                            java.lang.Object message,
                            org.springframework.amqp.core.MessagePostProcessor messagePostProcessor,
                            CorrelationData correlationData)
                     throws org.springframework.amqp.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
        correlationData - data to correlate publisher confirms.
        Throws:
        org.springframework.amqp.AmqpException - if there is a problem
      • convertSendAndReceive

        @Nullable
        java.lang.Object convertSendAndReceive​(java.lang.Object message,
                                               CorrelationData correlationData)
                                        throws org.springframework.amqp.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.
        correlationData - data to correlate publisher confirms.
        Returns:
        the response if there is one
        Throws:
        org.springframework.amqp.AmqpException - if there is a problem
      • convertSendAndReceive

        @Nullable
        java.lang.Object convertSendAndReceive​(java.lang.String routingKey,
                                               java.lang.Object message,
                                               CorrelationData correlationData)
                                        throws org.springframework.amqp.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
        correlationData - data to correlate publisher confirms.
        Returns:
        the response if there is one
        Throws:
        org.springframework.amqp.AmqpException - if there is a problem
      • convertSendAndReceive

        @Nullable
        java.lang.Object convertSendAndReceive​(java.lang.String exchange,
                                               java.lang.String routingKey,
                                               java.lang.Object message,
                                               CorrelationData correlationData)
                                        throws org.springframework.amqp.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
        correlationData - data to correlate publisher confirms.
        Returns:
        the response if there is one
        Throws:
        org.springframework.amqp.AmqpException - if there is a problem
      • convertSendAndReceive

        @Nullable
        java.lang.Object convertSendAndReceive​(java.lang.Object message,
                                               org.springframework.amqp.core.MessagePostProcessor messagePostProcessor,
                                               CorrelationData correlationData)
                                        throws org.springframework.amqp.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
        correlationData - data to correlate publisher confirms.
        Returns:
        the response if there is one
        Throws:
        org.springframework.amqp.AmqpException - if there is a problem
      • convertSendAndReceive

        @Nullable
        java.lang.Object convertSendAndReceive​(java.lang.String routingKey,
                                               java.lang.Object message,
                                               org.springframework.amqp.core.MessagePostProcessor messagePostProcessor,
                                               CorrelationData correlationData)
                                        throws org.springframework.amqp.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
        correlationData - data to correlate publisher confirms.
        Returns:
        the response if there is one
        Throws:
        org.springframework.amqp.AmqpException - if there is a problem
      • convertSendAndReceive

        @Nullable
        java.lang.Object convertSendAndReceive​(java.lang.String exchange,
                                               java.lang.String routingKey,
                                               java.lang.Object message,
                                               org.springframework.amqp.core.MessagePostProcessor messagePostProcessor,
                                               CorrelationData correlationData)
                                        throws org.springframework.amqp.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
        correlationData - data to correlate publisher confirms.
        Returns:
        the response if there is one
        Throws:
        org.springframework.amqp.AmqpException - if there is a problem
      • convertSendAndReceiveAsType

        @Nullable
        <T> T convertSendAndReceiveAsType​(java.lang.Object message,
                                          CorrelationData correlationData,
                                          org.springframework.core.ParameterizedTypeReference<T> responseType)
                                   throws org.springframework.amqp.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.
        correlationData - data to correlate publisher confirms.
        responseType - the type to convert the reply to.
        Returns:
        the response if there is one.
        Throws:
        org.springframework.amqp.AmqpException - if there is a problem.
      • convertSendAndReceiveAsType

        @Nullable
        <T> T convertSendAndReceiveAsType​(java.lang.String routingKey,
                                          java.lang.Object message,
                                          CorrelationData correlationData,
                                          org.springframework.core.ParameterizedTypeReference<T> responseType)
                                   throws org.springframework.amqp.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
        correlationData - data to correlate publisher confirms.
        responseType - the type to convert the reply to.
        Returns:
        the response if there is one
        Throws:
        org.springframework.amqp.AmqpException - if there is a problem
      • convertSendAndReceiveAsType

        @Nullable
        default <T> T convertSendAndReceiveAsType​(java.lang.String exchange,
                                                  java.lang.String routingKey,
                                                  java.lang.Object message,
                                                  @Nullable
                                                  CorrelationData correlationData,
                                                  org.springframework.core.ParameterizedTypeReference<T> responseType)
                                           throws org.springframework.amqp.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
        correlationData - data to correlate publisher confirms.
        responseType - the type to convert the reply to.
        Returns:
        the response if there is one
        Throws:
        org.springframework.amqp.AmqpException - if there is a problem
      • convertSendAndReceiveAsType

        @Nullable
        <T> T convertSendAndReceiveAsType​(java.lang.Object message,
                                          org.springframework.amqp.core.MessagePostProcessor messagePostProcessor,
                                          CorrelationData correlationData,
                                          org.springframework.core.ParameterizedTypeReference<T> responseType)
                                   throws org.springframework.amqp.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
        correlationData - data to correlate publisher confirms.
        responseType - the type to convert the reply to.
        Returns:
        the response if there is one
        Throws:
        org.springframework.amqp.AmqpException - if there is a problem
      • convertSendAndReceiveAsType

        @Nullable
        <T> T convertSendAndReceiveAsType​(java.lang.String routingKey,
                                          java.lang.Object message,
                                          org.springframework.amqp.core.MessagePostProcessor messagePostProcessor,
                                          CorrelationData correlationData,
                                          org.springframework.core.ParameterizedTypeReference<T> responseType)
                                   throws org.springframework.amqp.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
        correlationData - data to correlate publisher confirms.
        responseType - the type to convert the reply to.
        Returns:
        the response if there is one
        Throws:
        org.springframework.amqp.AmqpException - if there is a problem
      • convertSendAndReceiveAsType

        @Nullable
        <T> T convertSendAndReceiveAsType​(java.lang.String exchange,
                                          java.lang.String routingKey,
                                          java.lang.Object message,
                                          @Nullable
                                          org.springframework.amqp.core.MessagePostProcessor messagePostProcessor,
                                          @Nullable
                                          CorrelationData correlationData,
                                          org.springframework.core.ParameterizedTypeReference<T> responseType)
                                   throws org.springframework.amqp.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
        correlationData - data to correlate publisher confirms.
        responseType - the type to convert the reply to.
        Returns:
        the response if there is one
        Throws:
        org.springframework.amqp.AmqpException - if there is a problem
      • start

        default void start()
        Specified by:
        start in interface org.springframework.context.Lifecycle
      • stop

        default void stop()
        Specified by:
        stop in interface org.springframework.context.Lifecycle
      • isRunning

        default boolean isRunning()
        Specified by:
        isRunning in interface org.springframework.context.Lifecycle