Package: io.vertx.groovy.core.eventbus

## [Groovy] Class MessageConsumer<T>

- io.vertx.groovy.core.eventbus.MessageConsumer

- All Implemented Interfaces and Traits:
    ReadStream

      @groovy.transform.CompileStatic
      class MessageConsumer
      extends java.lang.Object

  An event bus consumer object representing a stream of message to an EventBus address that can be read from.

  The EventBus.consumer or EventBus.localConsumer creates a new consumer, the returned consumer is not yet registered against the event bus. Registration is effective after the MessageConsumer.handler method is invoked.

  The consumer is unregistered from the event bus using the MessageConsumer.unregister method or by calling the MessageConsumer.handler with a null value..

- - ### Constructor Summary

    Constructors
    Constructor and description
    `MessageConsumer (java.lang.Object delegate)`

  - ### Methods Summary

    Methods
    Type | Name and description
    --- | ---
    `java.lang.String` | `address()` @return The address the handler was registered with.
    `ReadStream<T>` | `bodyStream()` @return a read stream for the body of the message stream.
    `void` | `completionHandler(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> completionHandler)` Optional method which can be called to indicate when the registration has been propagated across the cluster.
    `MessageConsumer<T>` | `endHandler(io.vertx.core.Handler<java.lang.Void> endHandler)`
    `MessageConsumer<T>` | `exceptionHandler(io.vertx.core.Handler<java.lang.Throwable> handler)`
    `java.lang.Object` | `getDelegate()`
    `int` | `getMaxBufferedMessages()` @return the maximum number of messages that can be buffered when this stream is paused
    `MessageConsumer<T>` | `handler(io.vertx.core.Handler<Message<T>> handler)`
    `boolean` | `isRegistered()` @return true if the current consumer is registered
    `MessageConsumer<T>` | `pause()`
    `MessageConsumer<T>` | `resume()`
    `MessageConsumer<T>` | `setMaxBufferedMessages(int maxBufferedMessages)` Set the number of messages this registration will buffer when this stream is paused.
    `void` | `unregister()` Unregisters the handler which created this registration
    `void` | `unregister(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> completionHandler)` Unregisters the handler which created this registration

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class java.lang.Object` | `java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()`

- - ### Constructor Detail

    - #### MessageConsumer(java.lang.Object delegate)

  - ### Method Detail

    - #### java.lang.String address()

      Returns:
        The address the handler was registered with.

    - #### ReadStream<T> bodyStream()

      Returns:
        a read stream for the body of the message stream.

    - #### void completionHandler(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> completionHandler)

      Optional method which can be called to indicate when the registration has been propagated across the cluster.

      Parameters:
        `completionHandler` - the completion handler

    - #### MessageConsumer<T> endHandler(io.vertx.core.Handler<java.lang.Void> endHandler)

    - #### MessageConsumer<T> exceptionHandler(io.vertx.core.Handler<java.lang.Throwable> handler)

    - #### java.lang.Object getDelegate()

    - #### int getMaxBufferedMessages()

      Returns:
        the maximum number of messages that can be buffered when this stream is paused

    - #### MessageConsumer<T> handler(io.vertx.core.Handler<Message<T>> handler)

    - #### boolean isRegistered()

      Returns:
        true if the current consumer is registered

    - #### MessageConsumer<T> pause()

    - #### MessageConsumer<T> resume()

    - #### MessageConsumer<T> setMaxBufferedMessages(int maxBufferedMessages)

      Set the number of messages this registration will buffer when this stream is paused. The default value is `0`. When a new value is set, buffered messages may be discarded to reach the new value.

      Returns:
        this registration
      Parameters:
        `maxBufferedMessages` - the maximum number of messages that can be buffered

    - #### void unregister()

      Unregisters the handler which created this registration

    - #### void unregister(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> completionHandler)

      Unregisters the handler which created this registration

      Parameters:
        `completionHandler` - the handler called when the unregister is done. For example in a cluster when all nodes of the event bus have been unregistered.