Class RabbitMQPublisher

java.lang.Object
io.vertx.mutiny.rabbitmq.RabbitMQPublisher
All Implemented Interfaces:
MutinyDelegate

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

  • Field Details

  • Constructor Details

    • RabbitMQPublisher

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

      public RabbitMQPublisher(Object delegate)
  • Method Details

    • getDelegate

      public io.vertx.rabbitmq.RabbitMQPublisher getDelegate()
      Specified by:
      getDelegate in interface MutinyDelegate
      Returns:
      the delegate used by this Mutiny object of generated type
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • 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

      @CheckReturnValue 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

      @CheckReturnValue 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

      @CheckReturnValue 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.
    • publishAndForget

      public void publishAndForget(String exchange, String routingKey, com.rabbitmq.client.BasicProperties properties, Buffer body)
      Variant of publish(String,String,BasicProperties,io.vertx.mutiny.core.buffer.Buffer) that ignores the result of the operation.

      This method subscribes on the result of publish(String,String,BasicProperties,io.vertx.mutiny.core.buffer.Buffer), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from publish(String,String,BasicProperties,io.vertx.mutiny.core.buffer.Buffer) but you don't need to compose it with other operations.

      Parameters:
      exchange -
      routingKey -
      properties -
      body -
    • publishConfirm

      @CheckReturnValue public io.smallrye.mutiny.Uni<Long> publishConfirm(String exchange, String routingKey, com.rabbitmq.client.BasicProperties properties, Buffer body)
      Publish a message and complete when publish confirm has returned.

      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.
    • publishConfirmAndAwait

      public Long publishConfirmAndAwait(String exchange, String routingKey, com.rabbitmq.client.BasicProperties properties, Buffer body)
      Blocking variant of publishConfirm(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 Long instance produced by the operation.
    • publishConfirmAndForget

      public void publishConfirmAndForget(String exchange, String routingKey, com.rabbitmq.client.BasicProperties properties, Buffer body)
      Variant of publishConfirm(String,String,BasicProperties,io.vertx.mutiny.core.buffer.Buffer) that ignores the result of the operation.

      This method subscribes on the result of publishConfirm(String,String,BasicProperties,io.vertx.mutiny.core.buffer.Buffer), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from publishConfirm(String,String,BasicProperties,io.vertx.mutiny.core.buffer.Buffer) but you don't need to compose it with other operations.

      Parameters:
      exchange -
      routingKey -
      properties -
      body -
    • newInstance

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