Class RabbitMQClient


  • public class RabbitMQClient
    extends Object

    NOTE: This class has been automatically generated from the original non RX-ified interface using Vert.x codegen.

    • Field Detail

      • __TYPE_ARG

        public static final io.vertx.lang.rx.TypeArg<RabbitMQClient> __TYPE_ARG
    • Constructor Detail

      • RabbitMQClient

        public RabbitMQClient​(Object delegate)
    • Method Detail

      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • create

        public static RabbitMQClient create​(Vertx vertx)
        Create and return a client configured with the default options.
        Parameters:
        vertx - the vertx instance
        Returns:
        the client
      • create

        public static RabbitMQClient create​(Vertx vertx,
                                            RabbitMQOptions config)
        Create and return a client.
        Parameters:
        vertx - the vertx instance
        config - the client config
        Returns:
        the client
      • basicAck

        public Future<Void> basicAck​(long deliveryTag,
                                     boolean multiple)
        Acknowledge one or several received messages. Supply the deliveryTag from the AMQP.Basic.GetOk or AMQP.Basic.Deliver method containing the received message being acknowledged.
        Parameters:
        deliveryTag -
        multiple -
        Returns:
      • rxBasicAck

        public Completable rxBasicAck​(long deliveryTag,
                                      boolean multiple)
        Acknowledge one or several received messages. Supply the deliveryTag from the AMQP.Basic.GetOk or AMQP.Basic.Deliver method containing the received message being acknowledged.
        Parameters:
        deliveryTag -
        multiple -
        Returns:
      • basicNack

        public Future<Void> basicNack​(long deliveryTag,
                                      boolean multiple,
                                      boolean requeue)
        Reject one or several received messages.
        Parameters:
        deliveryTag -
        multiple -
        requeue -
        Returns:
      • rxBasicNack

        public Completable rxBasicNack​(long deliveryTag,
                                       boolean multiple,
                                       boolean requeue)
        Reject one or several received messages.
        Parameters:
        deliveryTag -
        multiple -
        requeue -
        Returns:
      • basicGet

        public Future<RabbitMQMessage> basicGet​(String queue,
                                                boolean autoAck)
        Retrieve a message from a queue using AMQP.Basic.Get
        Parameters:
        queue -
        autoAck -
        Returns:
      • rxBasicGet

        public Single<RabbitMQMessage> rxBasicGet​(String queue,
                                                  boolean autoAck)
        Retrieve a message from a queue using AMQP.Basic.Get
        Parameters:
        queue -
        autoAck -
        Returns:
      • basicConsumer

        public Future<RabbitMQConsumer> basicConsumer​(String queue,
                                                      QueueOptions options)
        Create a consumer with the given options.
        Parameters:
        queue - the name of a queue
        options - options for queue
        Returns:
      • rxBasicConsumer

        public Single<RabbitMQConsumer> rxBasicConsumer​(String queue,
                                                        QueueOptions options)
        Create a consumer with the given options.
        Parameters:
        queue - the name of a queue
        options - options for queue
        Returns:
      • basicPublish

        public Future<Void> basicPublish​(String exchange,
                                         String routingKey,
                                         Buffer body)
        Publish a message. Publishing to a non-existent exchange will result in a channel-level protocol exception, which closes the channel. Invocations of Channel#basicPublish will eventually block if a resource-driven alarm is in effect.
        Parameters:
        exchange -
        routingKey -
        body -
        Returns:
      • rxBasicPublish

        public Completable rxBasicPublish​(String exchange,
                                          String routingKey,
                                          Buffer body)
        Publish a message. Publishing to a non-existent exchange will result in a channel-level protocol exception, which closes the channel. Invocations of Channel#basicPublish will eventually block if a resource-driven alarm is in effect.
        Parameters:
        exchange -
        routingKey -
        body -
        Returns:
      • addConfirmListener

        public Future<ReadStream<RabbitMQConfirmation>> addConfirmListener​(int maxQueueSize)
        Add a Confirm Listener to the channel. Note that this will automatically call confirmSelect, it is not necessary to call that too.
        Parameters:
        maxQueueSize - maximum size of the queue of confirmations
        Returns:
      • rxAddConfirmListener

        public Single<ReadStream<RabbitMQConfirmation>> rxAddConfirmListener​(int maxQueueSize)
        Add a Confirm Listener to the channel. Note that this will automatically call confirmSelect, it is not necessary to call that too.
        Parameters:
        maxQueueSize - maximum size of the queue of confirmations
        Returns:
      • confirmSelect

        public Future<Void> confirmSelect()
        Enables publisher acknowledgements on this channel. Can be called once during client initialisation. Calls to basicPublish() will have to be confirmed.
        Returns:
      • rxConfirmSelect

        public Completable rxConfirmSelect()
        Enables publisher acknowledgements on this channel. Can be called once during client initialisation. Calls to basicPublish() will have to be confirmed.
        Returns:
      • waitForConfirms

        public Future<Void> waitForConfirms()
        Wait until all messages published since the last call have been either ack'd or nack'd by the broker. This will incur slight performance loss at the expense of higher write consistency. If desired, multiple calls to basicPublish() can be batched before confirming.
        Returns:
      • rxWaitForConfirms

        public Completable rxWaitForConfirms()
        Wait until all messages published since the last call have been either ack'd or nack'd by the broker. This will incur slight performance loss at the expense of higher write consistency. If desired, multiple calls to basicPublish() can be batched before confirming.
        Returns:
      • waitForConfirms

        public Future<Void> waitForConfirms​(long timeout)
        Wait until all messages published since the last call have been either ack'd or nack'd by the broker; or until timeout elapses. If the timeout expires a TimeoutException is thrown.
        Parameters:
        timeout -
        Returns:
      • rxWaitForConfirms

        public Completable rxWaitForConfirms​(long timeout)
        Wait until all messages published since the last call have been either ack'd or nack'd by the broker; or until timeout elapses. If the timeout expires a TimeoutException is thrown.
        Parameters:
        timeout -
        Returns:
      • basicQos

        public Future<Void> basicQos​(int prefetchCount)
        Request a specific prefetchCount "quality of service" settings for this channel.
        Parameters:
        prefetchCount - maximum number of messages that the server will deliver, 0 if unlimited
        Returns:
      • rxBasicQos

        public Completable rxBasicQos​(int prefetchCount)
        Request a specific prefetchCount "quality of service" settings for this channel.
        Parameters:
        prefetchCount - maximum number of messages that the server will deliver, 0 if unlimited
        Returns:
      • basicQos

        public Future<Void> basicQos​(int prefetchCount,
                                     boolean global)
        Request a specific prefetchCount "quality of service" settings for this channel.
        Parameters:
        prefetchCount - maximum number of messages that the server will deliver, 0 if unlimited
        global - true if the settings should be applied to the entire channel rather than each consumer
        Returns:
      • rxBasicQos

        public Completable rxBasicQos​(int prefetchCount,
                                      boolean global)
        Request a specific prefetchCount "quality of service" settings for this channel.
        Parameters:
        prefetchCount - maximum number of messages that the server will deliver, 0 if unlimited
        global - true if the settings should be applied to the entire channel rather than each consumer
        Returns:
      • basicQos

        public Future<Void> basicQos​(int prefetchSize,
                                     int prefetchCount,
                                     boolean global)
        Request specific "quality of service" settings. These settings impose limits on the amount of data the server will deliver to consumers before requiring acknowledgements. Thus they provide a means of consumer-initiated flow control.
        Parameters:
        prefetchSize - maximum amount of content (measured in octets) that the server will deliver, 0 if unlimited
        prefetchCount - maximum number of messages that the server will deliver, 0 if unlimited
        global - true if the settings should be applied to the entire channel rather than each consumer
        Returns:
      • rxBasicQos

        public Completable rxBasicQos​(int prefetchSize,
                                      int prefetchCount,
                                      boolean global)
        Request specific "quality of service" settings. These settings impose limits on the amount of data the server will deliver to consumers before requiring acknowledgements. Thus they provide a means of consumer-initiated flow control.
        Parameters:
        prefetchSize - maximum amount of content (measured in octets) that the server will deliver, 0 if unlimited
        prefetchCount - maximum number of messages that the server will deliver, 0 if unlimited
        global - true if the settings should be applied to the entire channel rather than each consumer
        Returns:
      • exchangeDeclare

        public Future<Void> exchangeDeclare​(String exchange,
                                            String type,
                                            boolean durable,
                                            boolean autoDelete)
        Declare an exchange.
        Parameters:
        exchange -
        type -
        durable -
        autoDelete -
        Returns:
      • rxExchangeDeclare

        public Completable rxExchangeDeclare​(String exchange,
                                             String type,
                                             boolean durable,
                                             boolean autoDelete)
        Declare an exchange.
        Parameters:
        exchange -
        type -
        durable -
        autoDelete -
        Returns:
      • exchangeDeclare

        public Future<Void> exchangeDeclare​(String exchange,
                                            String type,
                                            boolean durable,
                                            boolean autoDelete,
                                            JsonObject config)
        Declare an exchange with additional parameters such as dead lettering, an alternate exchange or TTL.
        Parameters:
        exchange -
        type -
        durable -
        autoDelete -
        config -
        Returns:
      • rxExchangeDeclare

        public Completable rxExchangeDeclare​(String exchange,
                                             String type,
                                             boolean durable,
                                             boolean autoDelete,
                                             JsonObject config)
        Declare an exchange with additional parameters such as dead lettering, an alternate exchange or TTL.
        Parameters:
        exchange -
        type -
        durable -
        autoDelete -
        config -
        Returns:
      • exchangeDelete

        public Future<Void> exchangeDelete​(String exchange)
        Delete an exchange, without regard for whether it is in use or not.
        Parameters:
        exchange -
        Returns:
      • rxExchangeDelete

        public Completable rxExchangeDelete​(String exchange)
        Delete an exchange, without regard for whether it is in use or not.
        Parameters:
        exchange -
        Returns:
      • exchangeBind

        public Future<Void> exchangeBind​(String destination,
                                         String source,
                                         String routingKey)
        Bind an exchange to an exchange.
        Parameters:
        destination -
        source -
        routingKey -
        Returns:
      • rxExchangeBind

        public Completable rxExchangeBind​(String destination,
                                          String source,
                                          String routingKey)
        Bind an exchange to an exchange.
        Parameters:
        destination -
        source -
        routingKey -
        Returns:
      • exchangeBind

        public Future<Void> exchangeBind​(String destination,
                                         String source,
                                         String routingKey,
                                         Map<String,​Object> arguments)
        Bind an exchange to an exchange.
        Parameters:
        destination -
        source -
        routingKey -
        arguments -
        Returns:
      • rxExchangeBind

        public Completable rxExchangeBind​(String destination,
                                          String source,
                                          String routingKey,
                                          Map<String,​Object> arguments)
        Bind an exchange to an exchange.
        Parameters:
        destination -
        source -
        routingKey -
        arguments -
        Returns:
      • exchangeUnbind

        public Future<Void> exchangeUnbind​(String destination,
                                           String source,
                                           String routingKey)
        Unbind an exchange from an exchange.
        Parameters:
        destination -
        source -
        routingKey -
        Returns:
      • rxExchangeUnbind

        public Completable rxExchangeUnbind​(String destination,
                                            String source,
                                            String routingKey)
        Unbind an exchange from an exchange.
        Parameters:
        destination -
        source -
        routingKey -
        Returns:
      • exchangeUnbind

        public Future<Void> exchangeUnbind​(String destination,
                                           String source,
                                           String routingKey,
                                           Map<String,​Object> arguments)
        Unbind an exchange from an exchange.
        Parameters:
        destination -
        source -
        routingKey -
        arguments -
        Returns:
      • rxExchangeUnbind

        public Completable rxExchangeUnbind​(String destination,
                                            String source,
                                            String routingKey,
                                            Map<String,​Object> arguments)
        Unbind an exchange from an exchange.
        Parameters:
        destination -
        source -
        routingKey -
        arguments -
        Returns:
      • queueDeclareAuto

        public Future<JsonObject> queueDeclareAuto()
        Actively declare a server-named exclusive, autodelete, non-durable queue.
        Returns:
      • rxQueueDeclareAuto

        public Single<JsonObject> rxQueueDeclareAuto()
        Actively declare a server-named exclusive, autodelete, non-durable queue.
        Returns:
      • queueBind

        public Future<Void> queueBind​(String queue,
                                      String exchange,
                                      String routingKey)
        Bind a queue to an exchange
        Parameters:
        queue -
        exchange -
        routingKey -
        Returns:
      • rxQueueBind

        public Completable rxQueueBind​(String queue,
                                       String exchange,
                                       String routingKey)
        Bind a queue to an exchange
        Parameters:
        queue -
        exchange -
        routingKey -
        Returns:
      • queueBind

        public Future<Void> queueBind​(String queue,
                                      String exchange,
                                      String routingKey,
                                      Map<String,​Object> arguments)
        Bind a queue to an exchange
        Parameters:
        queue -
        exchange -
        routingKey -
        arguments -
        Returns:
      • rxQueueBind

        public Completable rxQueueBind​(String queue,
                                       String exchange,
                                       String routingKey,
                                       Map<String,​Object> arguments)
        Bind a queue to an exchange
        Parameters:
        queue -
        exchange -
        routingKey -
        arguments -
        Returns:
      • queueUnbind

        public Future<Void> queueUnbind​(String queue,
                                        String exchange,
                                        String routingKey)
        Unbind a queue from an exchange
        Parameters:
        queue -
        exchange -
        routingKey -
        Returns:
      • rxQueueUnbind

        public Completable rxQueueUnbind​(String queue,
                                         String exchange,
                                         String routingKey)
        Unbind a queue from an exchange
        Parameters:
        queue -
        exchange -
        routingKey -
        Returns:
      • queueUnbind

        public Future<Void> queueUnbind​(String queue,
                                        String exchange,
                                        String routingKey,
                                        Map<String,​Object> arguments)
        Unbind a queue from an exchange
        Parameters:
        queue -
        exchange -
        routingKey -
        arguments -
        Returns:
      • rxQueueUnbind

        public Completable rxQueueUnbind​(String queue,
                                         String exchange,
                                         String routingKey,
                                         Map<String,​Object> arguments)
        Unbind a queue from an exchange
        Parameters:
        queue -
        exchange -
        routingKey -
        arguments -
        Returns:
      • messageCount

        public Future<Long> messageCount​(String queue)
        Returns the number of messages in a queue ready to be delivered.
        Parameters:
        queue -
        Returns:
      • rxMessageCount

        public Single<Long> rxMessageCount​(String queue)
        Returns the number of messages in a queue ready to be delivered.
        Parameters:
        queue -
        Returns:
      • start

        public Future<Void> start()
        Start the rabbitMQ client. Create the connection and the channel.
        Returns:
      • rxStart

        public Completable rxStart()
        Start the rabbitMQ client. Create the connection and the channel.
        Returns:
      • stop

        public Future<Void> stop()
        Stop the rabbitMQ client. Close the connection and its channel.
        Returns:
      • rxStop

        public Completable rxStop()
        Stop the rabbitMQ client. Close the connection and its channel.
        Returns:
      • isConnected

        public boolean isConnected()
        Check if a connection is open
        Returns:
        true when the connection is open, false otherwise
      • restartConnect

        public Future<Void> restartConnect​(int attempts)
        restart the rabbitMQ connect.
        Parameters:
        attempts - number of attempts
        Returns:
        a future notified when the operation is done with a result of the operation
      • rxRestartConnect

        public Completable rxRestartConnect​(int attempts)
        restart the rabbitMQ connect.
        Parameters:
        attempts - number of attempts
        Returns:
        a future notified when the operation is done with a result of the operation
      • isOpenChannel

        public boolean isOpenChannel()
        Check if a channel is open
        Returns:
        true when the connection is open, false otherwise
      • basicPublish

        public Future<Void> basicPublish​(String exchange,
                                         String routingKey,
                                         com.rabbitmq.client.BasicProperties properties,
                                         Buffer body)
        Publish a message. Publishing to a non-existent exchange will result in a channel-level protocol exception, which closes the channel. Invocations of Channel#basicPublish will eventually block if a resource-driven alarm is in effect.
        Parameters:
        exchange -
        routingKey -
        properties -
        body -
        Returns:
      • rxBasicPublish

        public Completable rxBasicPublish​(String exchange,
                                          String routingKey,
                                          com.rabbitmq.client.BasicProperties properties,
                                          Buffer body)
        Publish a message. Publishing to a non-existent exchange will result in a channel-level protocol exception, which closes the channel. Invocations of Channel#basicPublish will eventually block if a resource-driven alarm is in effect.
        Parameters:
        exchange -
        routingKey -
        properties -
        body -
        Returns:
      • basicPublishWithDeliveryTag

        public Future<Void> basicPublishWithDeliveryTag​(String exchange,
                                                        String routingKey,
                                                        com.rabbitmq.client.BasicProperties properties,
                                                        Buffer body,
                                                        Handler<Long> deliveryTagHandler)
        Publish a message. Publishing to a non-existent exchange will result in a channel-level protocol exception, which closes the channel. Invocations of Channel#basicPublish will eventually block if a resource-driven alarm is in effect. The deliveryTagHandler will be called before the message is sent, which is necessary because the confirmation may arrive asynchronously before the resultHandler is called.
        Parameters:
        exchange -
        routingKey -
        properties -
        body -
        deliveryTagHandler - callback to capture the deliveryTag for this message. Note that this will be called synchronously in the context of the client before the result is known.
        Returns:
      • rxBasicPublishWithDeliveryTag

        public Completable rxBasicPublishWithDeliveryTag​(String exchange,
                                                         String routingKey,
                                                         com.rabbitmq.client.BasicProperties properties,
                                                         Buffer body,
                                                         Handler<Long> deliveryTagHandler)
        Publish a message. Publishing to a non-existent exchange will result in a channel-level protocol exception, which closes the channel. Invocations of Channel#basicPublish will eventually block if a resource-driven alarm is in effect. The deliveryTagHandler will be called before the message is sent, which is necessary because the confirmation may arrive asynchronously before the resultHandler is called.
        Parameters:
        exchange -
        routingKey -
        properties -
        body -
        deliveryTagHandler - callback to capture the deliveryTag for this message. Note that this will be called synchronously in the context of the client before the result is known.
        Returns:
      • queueDeclare

        public Future<com.rabbitmq.client.AMQP.Queue.DeclareOk> queueDeclare​(String queue,
                                                                             boolean durable,
                                                                             boolean exclusive,
                                                                             boolean autoDelete)
        Declare a queue
        Parameters:
        queue -
        durable -
        exclusive -
        autoDelete -
        Returns:
      • rxQueueDeclare

        public Single<com.rabbitmq.client.AMQP.Queue.DeclareOk> rxQueueDeclare​(String queue,
                                                                               boolean durable,
                                                                               boolean exclusive,
                                                                               boolean autoDelete)
        Declare a queue
        Parameters:
        queue -
        durable -
        exclusive -
        autoDelete -
        Returns:
      • queueDeclare

        public Future<com.rabbitmq.client.AMQP.Queue.DeclareOk> queueDeclare​(String queue,
                                                                             boolean durable,
                                                                             boolean exclusive,
                                                                             boolean autoDelete,
                                                                             JsonObject config)
        Declare a queue with config options
        Parameters:
        queue -
        durable -
        exclusive -
        autoDelete -
        config -
        Returns:
      • rxQueueDeclare

        public Single<com.rabbitmq.client.AMQP.Queue.DeclareOk> rxQueueDeclare​(String queue,
                                                                               boolean durable,
                                                                               boolean exclusive,
                                                                               boolean autoDelete,
                                                                               JsonObject config)
        Declare a queue with config options
        Parameters:
        queue -
        durable -
        exclusive -
        autoDelete -
        config -
        Returns:
      • queueDelete

        public Future<com.rabbitmq.client.AMQP.Queue.DeleteOk> queueDelete​(String queue)
        Delete a queue, without regard for whether it is in use or has messages on it
        Parameters:
        queue -
        Returns:
      • rxQueueDelete

        public Single<com.rabbitmq.client.AMQP.Queue.DeleteOk> rxQueueDelete​(String queue)
        Delete a queue, without regard for whether it is in use or has messages on it
        Parameters:
        queue -
        Returns:
      • queueDeleteIf

        public Future<com.rabbitmq.client.AMQP.Queue.DeleteOk> queueDeleteIf​(String queue,
                                                                             boolean ifUnused,
                                                                             boolean ifEmpty)
        Delete a queue
        Parameters:
        queue -
        ifUnused -
        ifEmpty -
        Returns:
      • rxQueueDeleteIf

        public Single<com.rabbitmq.client.AMQP.Queue.DeleteOk> rxQueueDeleteIf​(String queue,
                                                                               boolean ifUnused,
                                                                               boolean ifEmpty)
        Delete a queue
        Parameters:
        queue -
        ifUnused -
        ifEmpty -
        Returns: