Class RabbitMQPublisher


  • public class RabbitMQPublisher
    extends Object
    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.

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

    • Constructor Detail

      • RabbitMQPublisher

        public RabbitMQPublisher​(io.vertx.rabbitmq.RabbitMQPublisher delegate)
      • RabbitMQPublisher

        public RabbitMQPublisher​(Object delegate)
    • Method Detail

      • getDelegate

        public io.vertx.rabbitmq.RabbitMQPublisher getDelegate()
      • hashCode

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

        public static RabbitMQPublisher create​(Vertx vertx,
                                               RabbitMQClient client,
                                               io.vertx.rabbitmq.RabbitMQPublisherOptions options)
        Parameters:
        vertx - the vertx instance.
        client - the RabbitMQClient.
        options - options for the publisher.
        Returns:
        the publisher
      • start

        public io.smallrye.mutiny.Uni<Void> start()
        Start the rabbitMQ publisher. The RabbitMQClient should have been started before this.

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • startAndAwait

        public Void startAndAwait()
        Blocking variant of start().

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Returns:
        the Void instance produced by the operation.
      • startAndForget

        public void startAndForget()
        Variant of start() that ignores the result of the operation.

        This method subscribes on the result of start(), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from start() but you don't need to compose it with other operations.

      • stop

        public io.smallrye.mutiny.Uni<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.

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • stopAndAwait

        public Void stopAndAwait()
        Blocking variant of stop().

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Returns:
        the Void instance produced by the operation.
      • stopAndForget

        public void stopAndForget()
        Variant of stop() that ignores the result of the operation.

        This method subscribes on the result of stop(), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from stop() but you don't need to compose it with other operations.

      • restart

        public void restart()
      • getConfirmationStream

        public ReadStream<io.vertx.rabbitmq.RabbitMQPublisherConfirmation> getConfirmationStream()
        Returns:
        the ReadStream that contains the message IDs for confirmed messages.
      • queueSize

        public int queueSize()
        Returns:
        the number of published, but not sent, messages.
      • publish

        public io.smallrye.mutiny.Uni<Void> publish​(String exchange,
                                                    String routingKey,
                                                    com.rabbitmq.client.BasicProperties properties,
                                                    Buffer body)
        Publish a message.

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Parameters:
        exchange -
        routingKey -
        properties -
        body -
        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • publishAndAwait

        public Void publishAndAwait​(String exchange,
                                    String routingKey,
                                    com.rabbitmq.client.BasicProperties properties,
                                    Buffer body)
        Blocking variant of publish(String,String,BasicProperties,io.vertx.mutiny.core.buffer.Buffer).

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Parameters:
        exchange -
        routingKey -
        properties -
        body -
        Returns:
        the Void instance produced by the operation.
      • newInstance

        public static RabbitMQPublisher newInstance​(io.vertx.rabbitmq.RabbitMQPublisher arg)