Package: io.vertx.groovy.core.eventbus

## [Groovy] Class EventBus

- io.vertx.groovy.core.eventbus.EventBus

- All Implemented Interfaces and Traits:
    Measured

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

  A Vert.x event-bus is a light-weight distributed messaging system which allows different parts of your application, or different applications and services to communicate with each in a loosely coupled way.

  An event-bus supports publish-subscribe messaging, point-to-point messaging and request-response messaging.

  Message delivery is best-effort and messages can be lost if failure of all or part of the event bus occurs.

  Please refer to the documentation for more information on the event bus.

- - ### Constructor Summary

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

  - ### Methods Summary

    Methods
    Type | Name and description
    --- | ---
    `EventBus` | `addInterceptor(io.vertx.core.Handler<SendContext> interceptor)` Add an interceptor that will be called whenever a message is sent from Vert.x
    `MessageConsumer<T>` | `consumer(java.lang.String address)` Create a message consumer against the specified address.
    `MessageConsumer<T>` | `consumer(java.lang.String address, io.vertx.core.Handler<Message<T>> handler)` Create a consumer and register it against the specified address.
    `java.lang.Object` | `getDelegate()`
    `boolean` | `isMetricsEnabled()` Whether the metrics are enabled for this measured object
    `MessageConsumer<T>` | `localConsumer(java.lang.String address)` Like EventBus.consumer but the address won't be propagated across the cluster.
    `MessageConsumer<T>` | `localConsumer(java.lang.String address, io.vertx.core.Handler<Message<T>> handler)` Like EventBus.consumer but the address won't be propagated across the cluster.
    `EventBus` | `publish(java.lang.String address, java.lang.Object message)` Publish a message.
    `EventBus` | `publish(java.lang.String address, java.lang.Object message, java.util.Map<java.lang.String, java.lang.Object> options)` Like EventBus.publish but specifying `options` that can be used to configure the delivery.
    `MessageProducer<T>` | `publisher(java.lang.String address)` Create a message publisher against the specified address.
    `MessageProducer<T>` | `publisher(java.lang.String address, java.util.Map<java.lang.String, java.lang.Object> options)` Like EventBus.publisher but specifying delivery options that will be used for configuring the delivery of the message.
    `EventBus` | `removeInterceptor(io.vertx.core.Handler<SendContext> interceptor)` Remove an interceptor
    `EventBus` | `send(java.lang.String address, java.lang.Object message)` Sends a message.
    `EventBus` | `send(java.lang.String address, java.lang.Object message, io.vertx.core.Handler<io.vertx.core.AsyncResult<Message<T>>> replyHandler)` Like EventBus.send but specifying a `replyHandler` that will be called if the recipient subsequently replies to the message.
    `EventBus` | `send(java.lang.String address, java.lang.Object message, java.util.Map<java.lang.String, java.lang.Object> options)` Like EventBus.send but specifying `options` that can be used to configure the delivery.
    `EventBus` | `send(java.lang.String address, java.lang.Object message, java.util.Map<java.lang.String, java.lang.Object> options, io.vertx.core.Handler<io.vertx.core.AsyncResult<Message<T>>> replyHandler)` Like EventBus.send but specifying a `replyHandler` that will be called if the recipient subsequently replies to the message.
    `MessageProducer<T>` | `sender(java.lang.String address)` Create a message sender against the specified address.
    `MessageProducer<T>` | `sender(java.lang.String address, java.util.Map<java.lang.String, java.lang.Object> options)` Like EventBus.sender but specifying delivery options that will be used for configuring the delivery of the message.

  - ### 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

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

  - ### Method Detail

    - #### EventBus addInterceptor(io.vertx.core.Handler<SendContext> interceptor)

      Add an interceptor that will be called whenever a message is sent from Vert.x

      Returns:
        a reference to this, so the API can be used fluently
      Parameters:
        `interceptor` - the interceptor

    - #### MessageConsumer<T> consumer(java.lang.String address)

      Create a message consumer against the specified address.

      The returned consumer is not yet registered at the address, registration will be effective when MessageConsumer.handler is called.

      Returns:
        the event bus message consumer
      Parameters:
        `address` - the address that it will register it at

    - #### MessageConsumer<T> consumer(java.lang.String address, io.vertx.core.Handler<Message<T>> handler)

      Create a consumer and register it against the specified address.

      Returns:
        the event bus message consumer
      Parameters:
        `address` - the address that will register it at
        `handler` - the handler that will process the received messages

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

    - #### boolean isMetricsEnabled()

      Whether the metrics are enabled for this measured object

      Returns:
        true if the metrics are enabled

    - #### MessageConsumer<T> localConsumer(java.lang.String address)

      Like EventBus.consumer but the address won't be propagated across the cluster.

      Returns:
        the event bus message consumer
      Parameters:
        `address` - the address to register it at

    - #### MessageConsumer<T> localConsumer(java.lang.String address, io.vertx.core.Handler<Message<T>> handler)

      Like EventBus.consumer but the address won't be propagated across the cluster.

      Returns:
        the event bus message consumer
      Parameters:
        `address` - the address that will register it at
        `handler` - the handler that will process the received messages

    - #### EventBus publish(java.lang.String address, java.lang.Object message)

      Publish a message.

      The message will be delivered to all handlers registered to the address.

      Returns:
        a reference to this, so the API can be used fluently
      Parameters:
        `address` - the address to publish it to
        `message` - the message, may be `null`

    - #### EventBus publish(java.lang.String address, java.lang.Object message, java.util.Map<java.lang.String, java.lang.Object> options)

      Like EventBus.publish but specifying `options` that can be used to configure the delivery.

      Returns:
        a reference to this, so the API can be used fluently
      Parameters:
        `address` - the address to publish it to
        `message` - the message, may be `null`
        `options` - the delivery options (see DeliveryOptions)

    - #### MessageProducer<T> publisher(java.lang.String address)

      Create a message publisher against the specified address.

      The returned publisher will invoke the EventBus.publish method when the stream WriteStream.write method is called with the publisher address and the provided data.

      Returns:
        The publisher
      Parameters:
        `address` - The address to publish it to

    - #### MessageProducer<T> publisher(java.lang.String address, java.util.Map<java.lang.String, java.lang.Object> options)

      Like EventBus.publisher but specifying delivery options that will be used for configuring the delivery of the message.

      Returns:
        The publisher
      Parameters:
        `address` - the address to publish it to
        `options` - the delivery options (see DeliveryOptions)

    - #### EventBus removeInterceptor(io.vertx.core.Handler<SendContext> interceptor)

      Remove an interceptor

      Returns:
        a reference to this, so the API can be used fluently
      Parameters:
        `interceptor` - the interceptor

    - #### EventBus send(java.lang.String address, java.lang.Object message)

      Sends a message.

      The message will be delivered to at most one of the handlers registered to the address.

      Returns:
        a reference to this, so the API can be used fluently
      Parameters:
        `address` - the address to send it to
        `message` - the message, may be `null`

    - #### EventBus send(java.lang.String address, java.lang.Object message, io.vertx.core.Handler<io.vertx.core.AsyncResult<Message<T>>> replyHandler)

      Like EventBus.send but specifying a `replyHandler` that will be called if the recipient subsequently replies to the message.

      Returns:
        a reference to this, so the API can be used fluently
      Parameters:
        `address` - the address to send it to
        `message` - the message, may be `null`
        `replyHandler` - reply handler will be called when any reply from the recipient is received, may be `null`

    - #### EventBus send(java.lang.String address, java.lang.Object message, java.util.Map<java.lang.String, java.lang.Object> options)

      Like EventBus.send but specifying `options` that can be used to configure the delivery.

      Returns:
        a reference to this, so the API can be used fluently
      Parameters:
        `address` - the address to send it to
        `message` - the message, may be `null`
        `options` - delivery options (see DeliveryOptions)

    - #### EventBus send(java.lang.String address, java.lang.Object message, java.util.Map<java.lang.String, java.lang.Object> options, io.vertx.core.Handler<io.vertx.core.AsyncResult<Message<T>>> replyHandler)

      Like EventBus.send but specifying a `replyHandler` that will be called if the recipient subsequently replies to the message.

      Returns:
        a reference to this, so the API can be used fluently
      Parameters:
        `address` - the address to send it to
        `message` - the message, may be `null`
        `options` - delivery options (see DeliveryOptions)
        `replyHandler` - reply handler will be called when any reply from the recipient is received, may be `null`

    - #### MessageProducer<T> sender(java.lang.String address)

      Create a message sender against the specified address.

      The returned sender will invoke the EventBus.send method when the stream WriteStream.write method is called with the sender address and the provided data.

      Returns:
        The sender
      Parameters:
        `address` - the address to send it to

    - #### MessageProducer<T> sender(java.lang.String address, java.util.Map<java.lang.String, java.lang.Object> options)

      Like EventBus.sender but specifying delivery options that will be used for configuring the delivery of the message.

      Returns:
        The sender
      Parameters:
        `address` - the address to send it to
        `options` - the delivery options (see DeliveryOptions)