Package io.vertx.rabbitmq

## Interface RabbitMQPublisher

-     public interface RabbitMQPublisher

  A reliable publisher that
  - Queues up messages internally until it can successfully call basicPublish.
  - Notifies the caller using a robust ID (not delivery tag) when the message is confirmed by rabbit.
  This is a layer above the RabbitMQClient that provides a lot of standard implementation when guaranteed at least once delivery is required. If confirmations are not required do not use this publisher as it does have overhead.
  Author:
    jtalbut

- - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static RabbitMQPublisher` | `create​(Vertx vertx, RabbitMQClient client, RabbitMQPublisherOptions options)` | Create and return a publisher using the specified client.
    `ReadStream<RabbitMQPublisherConfirmation>` | `getConfirmationStream()` | Get the ReadStream that contains the message IDs for confirmed messages.
    `Future<Void>` | `publish​(String exchange, String routingKey, com.rabbitmq.client.BasicProperties properties, Buffer body)` | Publish a message.
    `Future<Long>` | `publishConfirm​(String exchange, String routingKey, com.rabbitmq.client.BasicProperties properties, Buffer body)` | Publish a message and complete when publish confirm has returned.
    `int` | `queueSize()` | Get the number of published, but not sent, messages.
    `void` | `restart()` | Undo the effects of calling `#stop(Handler)` so that publish may be called again.
    `Future<Void>` | `start()` | Start the rabbitMQ publisher.
    `Future<Void>` | `stop()` | Stop the rabbitMQ publisher.

- - ### Method Detail

    - #### create

          static RabbitMQPublisher create​(Vertx vertx,
                                          RabbitMQClient client,
                                          RabbitMQPublisherOptions options)

      Create and return a publisher using the specified client.
      Parameters:
        `vertx` - the vertx instance.
        `client` - the RabbitMQClient.
        `options` - options for the publisher.
      Returns:
        the publisher

    - #### start

          Future<Void> start()

      Start the rabbitMQ publisher. The RabbitMQClient should have been started before this.

    - #### stop

          Future<Void> stop()

      Stop the rabbitMQ publisher. Calling this is optional, but it gives the opportunity to drain the send queue without losing messages. Future calls to publish will be ignored.

    - #### restart

          void restart()

      Undo the effects of calling `#stop(Handler)` so that publish may be called again. It is harmless to call restart() when `#stop(Handler)` has not been called, however if restart() is called whilst `#stop(Handler)` is being processed the `#stop(Handler)` will never complete.

    - #### getConfirmationStream

          ReadStream<RabbitMQPublisherConfirmation> getConfirmationStream()

      Get the ReadStream that contains the message IDs for confirmed messages. The message IDs in this ReadStream are taken from the message properties, if these message IDs are not set then this ReadStream will contain nulls and using this publisher will be pointless.
      Returns:
        the ReadStream that contains the message IDs for confirmed messages.

    - #### publish

          Future<Void> publish​(String exchange,
                               String routingKey,
                               com.rabbitmq.client.BasicProperties properties,
                               Buffer body)

      Publish a message.
      See Also:
        `Channel.basicPublish(String, String, AMQP.BasicProperties, byte[])`

    - #### publishConfirm

          Future<Long> publishConfirm​(String exchange,
                                      String routingKey,
                                      com.rabbitmq.client.BasicProperties properties,
                                      Buffer body)

      Publish a message and complete when publish confirm has returned.
      See Also:
        `Channel.basicPublish(String, String, AMQP.BasicProperties, byte[])`

    - #### queueSize

          int queueSize()

      Get the number of published, but not sent, messages.
      Returns:
        the number of published, but not sent, messages.