Class MessageConsumer<T>

java.lang.Object
io.vertx.mutiny.core.eventbus.MessageConsumer<T>
All Implemented Interfaces:
MutinyDelegate, ReadStream<Message<T>>, StreamBase

public class MessageConsumer<T> extends Object implements ReadStream<Message<T>>, MutinyDelegate
An event bus consumer object representing a stream of message to an EventBus address that can be read from.

The EventBus.consumer(String) or EventBus.localConsumer(String) creates a new consumer, the returned consumer is not yet registered against the event bus. Registration is effective after the #handler(io.vertx.core.Handler) method is invoked.

The consumer is unregistered from the event bus using the unregister() method or by calling the #handler(io.vertx.core.Handler) with a null value..

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

Author:
Nick Scavelli
See Also:
  • MessageConsumer
  • Field Details

  • Constructor Details

    • MessageConsumer

      public MessageConsumer(io.vertx.core.eventbus.MessageConsumer<T> delegate)
      Create a new instance of MessageConsumer delegating to the given (non-null) instance of MessageConsumer.
    • MessageConsumer

      public MessageConsumer(io.vertx.core.eventbus.MessageConsumer<T> delegate, TypeArg<T> typeArg_0)
    • MessageConsumer

      public MessageConsumer(Object delegate, TypeArg<T> typeArg_0)
  • Method Details

    • getDelegate

      public io.vertx.core.eventbus.MessageConsumer<T> 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<T>
      Specified by:
      getDelegate in interface StreamBase
      Returns:
      the delegate instance
    • completion

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> completion()

      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:
      • MessageConsumer.completion()
    • completionAndAwait

      public void completionAndAwait()

      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:
      • MessageConsumer.completion()
    • completionAndForget

      public MessageConsumer<T> completionAndForget()

      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:
      • MessageConsumer.completion()
    • unregister

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> unregister()
      Unregisters the handler which created this registration

      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:
      • MessageConsumer.unregister()
    • unregisterAndAwait

      public void unregisterAndAwait()
      Unregisters the handler which created this registration

      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:
      • MessageConsumer.unregister()
    • unregisterAndForget

      public MessageConsumer<T> unregisterAndForget()
      Unregisters the handler which created this registration

      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:
      • MessageConsumer.unregister()
    • pipeTo

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> pipeTo(WriteStream<Message<T>> arg0)
      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<T>
      Parameters:
      dst - the destination write stream
      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • io.vertx.core.eventbus.MessageConsumer#pipeTo(WriteStream)
    • pipeToAndAwait

      public void pipeToAndAwait(WriteStream<Message<T>> arg0)
      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.core.eventbus.MessageConsumer#pipeTo(WriteStream)
    • pipeToAndForget

      public MessageConsumer<T> pipeToAndForget(WriteStream<Message<T>> arg0)
      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.core.eventbus.MessageConsumer#pipeTo(WriteStream)
    • exceptionHandler

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

      public MessageConsumer<T> handler(Consumer<Message<T>> handler)
      Description copied from interface: ReadStream
      Set a data handler. As data is read, the handler will be called with the data.
      Specified by:
      handler in interface ReadStream<T>
      Returns:
      a reference to this, so the API can be used fluently
    • pause

      public MessageConsumer<T> pause()
      Description copied from interface: ReadStream
      Pause the ReadStream, it sets the buffer in fetch mode and clears the actual demand.

      While it's paused, no data will be sent to the data handler.

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

      public MessageConsumer<T> resume()
      Description copied from interface: ReadStream
      Resume reading, and sets the buffer in flowing mode.

      If the ReadStream has been paused, reading will recommence on it.

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

      public MessageConsumer<T> fetch(long amount)
      Description copied from interface: ReadStream
      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<T>
      Returns:
      a reference to this, so the API can be used fluently
    • endHandler

      public MessageConsumer<T> endHandler(Runnable endHandler)
      Description copied from interface: ReadStream
      Set an end handler. Once the stream has ended, and there is no more data to be read, this handler will be called.
      Specified by:
      endHandler in interface ReadStream<T>
      Returns:
      a reference to this, so the API can be used fluently
    • bodyStream

      public ReadStream<T> bodyStream()
      Returns:
      a read stream for the body of the message stream.
    • isRegistered

      public boolean isRegistered()
      Returns:
      true if the current consumer is registered
    • address

      public String address()
      Returns:
      The address the handler was registered with.
    • pipe

      public Pipe<Message<T>> 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<T>
      Returns:
      a pipe
    • newInstance

      public static <T> MessageConsumer<T> newInstance(io.vertx.core.eventbus.MessageConsumer<T> delegate)
      Creates a new instance of the MessageConsumer.
    • newInstance

      public static <T> MessageConsumer<T> newInstance(io.vertx.core.eventbus.MessageConsumer<T> delegate, TypeArg<T> typeArg_0)
      Creates a new instance of the MessageConsumer.
    • 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<Message<T>> toMulti()
    • toBlockingIterable

      public Iterable<Message<T>> toBlockingIterable()
    • toBlockingStream

      public Stream<Message<T>> toBlockingStream()