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.

Author:
jtalbut
See Also:
  • RabbitMQPublisher
  • Field Details

  • Constructor Details

    • RabbitMQPublisher

      public RabbitMQPublisher(io.vertx.rabbitmq.RabbitMQPublisher delegate)
      Create a new instance of RabbitMQPublisher delegating to the given (non-null) instance of RabbitMQPublisher.
    • RabbitMQPublisher

      public RabbitMQPublisher(Object delegate)
  • Method Details

    • getDelegate

      public io.vertx.rabbitmq.RabbitMQPublisher getDelegate()
      Get the delegate instance.

      This method returns the instance on which this shim is delegating the calls. And so, give you access to the bare API.

      Specified by:
      getDelegate in interface MutinyDelegate
      Returns:
      the delegate instance
    • 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. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • RabbitMQPublisher.start()
    • startAndAwait

      public void startAndAwait()
      Start the rabbitMQ publisher. The RabbitMQClient should have been started before this.

      Unlike the bare Vert.x variant, this method returns a Void. This method awaits indefinitely 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).

      See Also:
      • RabbitMQPublisher.start()
    • startAndForget

      public RabbitMQPublisher startAndForget()
      Start the rabbitMQ publisher. The RabbitMQClient should have been started before this.

      Unlike the bare Vert.x variant, this method ignores the Void result or any failure.

      Returns:
      The current instance to chain operations if needed.
      See Also:
      • RabbitMQPublisher.start()
    • 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. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • RabbitMQPublisher.stop()
    • stopAndAwait

      public void stopAndAwait()
      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 Void. This method awaits indefinitely 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).

      See Also:
      • RabbitMQPublisher.stop()
    • stopAndForget

      public RabbitMQPublisher stopAndForget()
      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 ignores the Void result or any failure.

      Returns:
      The current instance to chain operations if needed.
      See Also:
      • RabbitMQPublisher.stop()
    • publish

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

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • Channel.basicPublish(String, String, AMQP.BasicProperties, byte[])
      • RabbitMQPublisher.publish(String, String, BasicProperties, Buffer)
    • publishAndAwait

      public void publishAndAwait(String exchange, String routingKey, com.rabbitmq.client.BasicProperties properties, io.vertx.core.buffer.Buffer body)
      Publish a message.

      Unlike the bare Vert.x variant, this method returns a Void. This method awaits indefinitely 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).

      See Also:
      • Channel.basicPublish(String, String, AMQP.BasicProperties, byte[])
      • RabbitMQPublisher.publish(String, String, BasicProperties, Buffer)
    • publishAndForget

      public RabbitMQPublisher publishAndForget(String exchange, String routingKey, com.rabbitmq.client.BasicProperties properties, io.vertx.core.buffer.Buffer body)
      Publish a message.

      Unlike the bare Vert.x variant, this method ignores the Void result or any failure.

      Returns:
      The current instance to chain operations if needed.
      See Also:
      • Channel.basicPublish(String, String, AMQP.BasicProperties, byte[])
      • RabbitMQPublisher.publish(String, String, BasicProperties, Buffer)
    • publishConfirm

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

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • Channel.basicPublish(String, String, AMQP.BasicProperties, byte[])
      • RabbitMQPublisher.publishConfirm(String, String, BasicProperties, Buffer)
    • publishConfirmAndAwait

      public Long publishConfirmAndAwait(String exchange, String routingKey, com.rabbitmq.client.BasicProperties properties, io.vertx.core.buffer.Buffer body)
      Publish a message and complete when publish confirm has returned.

      Unlike the bare Vert.x variant, this method returns a Long. This method awaits indefinitely 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 operation result
      See Also:
      • Channel.basicPublish(String, String, AMQP.BasicProperties, byte[])
      • RabbitMQPublisher.publishConfirm(String, String, BasicProperties, Buffer)
    • publishConfirmAndForget

      public RabbitMQPublisher publishConfirmAndForget(String exchange, String routingKey, com.rabbitmq.client.BasicProperties properties, io.vertx.core.buffer.Buffer body)
      Publish a message and complete when publish confirm has returned.

      Unlike the bare Vert.x variant, this method ignores the Long result or any failure.

      Returns:
      The current instance to chain operations if needed.
      See Also:
      • Channel.basicPublish(String, String, AMQP.BasicProperties, byte[])
      • RabbitMQPublisher.publishConfirm(String, String, BasicProperties, Buffer)
    • create

      public static RabbitMQPublisher create(Vertx vertx, RabbitMQClient client, io.vertx.rabbitmq.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
    • restart

      public 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

      public ReadStream<io.vertx.rabbitmq.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.
    • queueSize

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

      public static RabbitMQPublisher newInstance(io.vertx.rabbitmq.RabbitMQPublisher delegate)
      Creates a new instance of the RabbitMQPublisher.
    • hashCode

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

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object