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 MutinyDelegate, ReadStream<Message<T>>
An event bus consumer object representing a stream of message to an EventBus address that can be read from.

The EventBus.consumer(java.lang.String) or EventBus.localConsumer(java.lang.String) creates a new consumer, the returned consumer is not yet registered against the event bus. Registration is effective after the handler(java.util.function.Consumer<io.vertx.mutiny.core.eventbus.Message<T>>) method is invoked.

The consumer is unregistered from the event bus using the unregister() method or by calling the handler(java.util.function.Consumer<io.vertx.mutiny.core.eventbus.Message<T>>) with a null value..

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

  • Field Details

  • Constructor Details

    • MessageConsumer

      public MessageConsumer(io.vertx.core.eventbus.MessageConsumer delegate)
    • MessageConsumer

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

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

    • getDelegate

      public io.vertx.core.eventbus.MessageConsumer getDelegate()
      Specified by:
      getDelegate in interface MutinyDelegate
      Specified by:
      getDelegate in interface ReadStream<T>
      Specified by:
      getDelegate in interface StreamBase
      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
    • pipe

      public Pipe<Message<T>> pipe()
      Specified by:
      pipe in interface ReadStream<T>
      Returns:
      a pipe
    • pipeTo

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> pipeTo(WriteStream<Message<T>> 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.

      Once this stream has ended or failed, the write stream will be ended and the handler will be called with the result.

      Unlike the bare Vert.x variant, this method returns a Uni. 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:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • pipeToAndAwait

      public Void pipeToAndAwait(WriteStream<Message<T>> dst)
      Blocking variant of ReadStream.pipeTo(io.vertx.mutiny.core.streams.WriteStream).

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

      Specified by:
      pipeToAndAwait in interface ReadStream<T>
      Parameters:
      dst - the destination write stream
      Returns:
      the Void instance produced by the operation.
    • pipeToAndForget

      public void pipeToAndForget(WriteStream<Message<T>> dst)
      Variant of ReadStream.pipeTo(io.vertx.mutiny.core.streams.WriteStream) that ignores the result of the operation.

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

      Specified by:
      pipeToAndForget in interface ReadStream<T>
      Parameters:
      dst - the destination write stream
    • exceptionHandler

      public MessageConsumer<T> exceptionHandler(Consumer<Throwable> handler)
      Specified by:
      exceptionHandler in interface ReadStream<T>
      Specified by:
      exceptionHandler in interface StreamBase
      Parameters:
      handler - the exception handler
      Returns:
    • handler

      public MessageConsumer<T> handler(Consumer<Message<T>> handler)
      Specified by:
      handler in interface ReadStream<T>
      Returns:
    • pause

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

      public MessageConsumer<T> resume()
      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)
      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)
      Specified by:
      endHandler in interface ReadStream<T>
      Returns:
    • 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.
    • setMaxBufferedMessages

      public MessageConsumer<T> setMaxBufferedMessages(int maxBufferedMessages)
      Parameters:
      maxBufferedMessages - the maximum number of messages that can be buffered
      Returns:
      this registration
    • getMaxBufferedMessages

      public int getMaxBufferedMessages()
      Returns:
      the maximum number of messages that can be buffered when this stream is paused
    • completionHandler

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> completionHandler()
      Optional method which can be called to indicate when the registration has been propagated across the cluster.

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

      public Void completionHandlerAndAwait()
      Blocking variant of completionHandler().

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

      public void completionHandlerAndForget()
      Variant of completionHandler() that ignores the result of the operation.

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

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

      public Void unregisterAndAwait()
      Blocking variant of unregister().

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

      public void unregisterAndForget()
      Variant of unregister() that ignores the result of the operation.

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

    • toMulti

      @CheckReturnValue public io.smallrye.mutiny.Multi<Message<T>> toMulti()
      Specified by:
      toMulti in interface ReadStream<T>
    • toBlockingIterable

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

      public Stream<Message<T>> toBlockingStream()
    • newInstance

      public static <T> MessageConsumer<T> newInstance(io.vertx.core.eventbus.MessageConsumer arg)
    • newInstance

      public static <T> MessageConsumer<T> newInstance(io.vertx.core.eventbus.MessageConsumer arg, TypeArg<T> __typeArg_T)