Interface RabbitOperations

    • Method Detail

      • 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 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:
        AmqpException - if one occurs.
        Since:
        2.0
        See Also:
        Channel.waitForConfirms(long)
      • waitForConfirmsOrDie

        void waitForConfirmsOrDie​(long timeout)
                           throws 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:
        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​(String routingKey,
                          Message message,
                          CorrelationData correlationData)
                   throws 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:
        AmqpException - if there is a problem
        Since:
        2.3
      • send

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        default void start()
        Specified by:
        start in interface Lifecycle
      • stop

        default void stop()
        Specified by:
        stop in interface Lifecycle
      • isRunning

        default boolean isRunning()
        Specified by:
        isRunning in interface Lifecycle