Class RabbitMQConsumer

java.lang.Object
io.vertx.mutiny.rabbitmq.RabbitMQConsumer
All Implemented Interfaces:
MutinyDelegate, ReadStream<RabbitMQMessage>, StreamBase

public class RabbitMQConsumer extends Object implements ReadStream<RabbitMQMessage>, MutinyDelegate
A stream of messages from a rabbitmq queue.

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

See Also:
  • RabbitMQConsumer
  • Field Details

  • Constructor Details

    • RabbitMQConsumer

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

      public RabbitMQConsumer(Object delegate)
  • Method Details

    • getDelegate

      public io.vertx.rabbitmq.RabbitMQConsumer 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
      Specified by:
      getDelegate in interface ReadStream<RabbitMQMessage>
      Specified by:
      getDelegate in interface StreamBase
      Returns:
      the delegate instance
    • cancel

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> cancel()
      Stop message consumption from a queue.

      The operation is asynchronous. When consumption is stopped, you can also be notified via RabbitMQConsumer#endHandler(Handler)

      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:
      • RabbitMQConsumer.cancel()
    • cancelAndAwait

      public void cancelAndAwait()
      Stop message consumption from a queue.

      The operation is asynchronous. When consumption is stopped, you can also be notified via RabbitMQConsumer#endHandler(Handler)

      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:
      • RabbitMQConsumer.cancel()
    • cancelAndForget

      public RabbitMQConsumer cancelAndForget()
      Stop message consumption from a queue.

      The operation is asynchronous. When consumption is stopped, you can also be notified via RabbitMQConsumer#endHandler(Handler)

      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:
      • RabbitMQConsumer.cancel()
    • pipeTo

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> pipeTo(WriteStream<RabbitMQMessage> dst)
      Pipe this ReadStream to the WriteStream.

      Elements emitted by this stream will be written to the write stream until this stream ends or fails.

      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.

      Specified by:
      pipeTo in interface ReadStream<RabbitMQMessage>
      Parameters:
      dst - the destination write stream
      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • io.vertx.rabbitmq.RabbitMQConsumer#pipeTo(WriteStream)
    • pipeToAndAwait

      public void pipeToAndAwait(WriteStream<RabbitMQMessage> dst)
      Pipe this ReadStream to the WriteStream.

      Elements emitted by this stream will be written to the write stream until this stream ends or fails.

      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).

      Parameters:
      dst - the destination write stream
      See Also:
      • io.vertx.rabbitmq.RabbitMQConsumer#pipeTo(WriteStream)
    • pipeToAndForget

      public RabbitMQConsumer pipeToAndForget(WriteStream<RabbitMQMessage> dst)
      Pipe this ReadStream to the WriteStream.

      Elements emitted by this stream will be written to the write stream until this stream ends or fails.

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

      Parameters:
      dst - the destination write stream
      Returns:
      The current instance to chain operations if needed.
      See Also:
      • io.vertx.rabbitmq.RabbitMQConsumer#pipeTo(WriteStream)
    • exceptionHandler

      public RabbitMQConsumer exceptionHandler(Consumer<Throwable> exceptionHandler)
      Set an exception handler on the read stream.
      Specified by:
      exceptionHandler in interface ReadStream<RabbitMQMessage>
      Specified by:
      exceptionHandler in interface StreamBase
      Parameters:
      exceptionHandler - the exception handler
      Returns:
      a reference to this, so the API can be used fluently
    • handler

      public RabbitMQConsumer handler(Consumer<RabbitMQMessage> messageArrived)
      Set a message handler. As message appear in a queue, the handler will be called with the message.
      Specified by:
      handler in interface ReadStream<RabbitMQMessage>
      Returns:
      a reference to this, so the API can be used fluently
    • pause

      public RabbitMQConsumer pause()
      Pause the stream of incoming messages from queue.

      The messages will continue to arrive, but they will be stored in a internal queue. If the queue size would exceed the limit provided by RabbitMQConsumer#size(int), then incoming messages will be discarded.

      Specified by:
      pause in interface ReadStream<RabbitMQMessage>
      Returns:
      a reference to this, so the API can be used fluently
    • resume

      public RabbitMQConsumer resume()
      Resume reading from a queue. Flushes internal queue.
      Specified by:
      resume in interface ReadStream<RabbitMQMessage>
      Returns:
      a reference to this, so the API can be used fluently
    • endHandler

      public RabbitMQConsumer endHandler(Runnable endHandler)
      Set an end handler. Once the stream has canceled successfully, the handler will be called.
      Specified by:
      endHandler in interface ReadStream<RabbitMQMessage>
      Returns:
      a reference to this, so the API can be used fluently
    • queueName

      public String queueName()
      Returns:
      the name of the queue
    • setQueueName

      public RabbitMQConsumer setQueueName(String name)
      Set the name of the queue. This method is typically only required during a connectionEstablishedCallback when the queue name has changed.
      Parameters:
      name - the name of the queue
      Returns:
      a reference to this, so the API can be used fluently
    • consumerTag

      public String consumerTag()
      Returns:
      a consumer tag
    • isCancelled

      public boolean isCancelled()
      Return true if cancel() has been called.
      Returns:
      true if cancel() has been called.
    • isPaused

      public boolean isPaused()
      Returns:
      is the stream paused?
    • fetch

      public RabbitMQConsumer fetch(long amount)
      Fetch the specified amount of elements. If the ReadStream has been paused, reading will recommence with the specified amount of items, otherwise the specified amount will be added to the current stream demand.
      Specified by:
      fetch in interface ReadStream<RabbitMQMessage>
      Returns:
      a reference to this, so the API can be used fluently
    • pipe

      public Pipe<RabbitMQMessage> pipe()
      Pause this stream and return a Pipe to transfer the elements of this stream to a destination WriteStream.

      The stream will be resumed when the pipe will be wired to a WriteStream.

      Specified by:
      pipe in interface ReadStream<RabbitMQMessage>
      Returns:
      a pipe
    • newInstance

      public static RabbitMQConsumer newInstance(io.vertx.rabbitmq.RabbitMQConsumer delegate)
      Creates a new instance of the RabbitMQConsumer.
    • 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
    • toMulti

      @CheckReturnValue public io.smallrye.mutiny.Multi<RabbitMQMessage> toMulti()
    • toBlockingIterable

      public Iterable<RabbitMQMessage> toBlockingIterable()
    • toBlockingStream

      public Stream<RabbitMQMessage> toBlockingStream()