# Class: EventBus

## vertx-js/event_bus~ EventBus

#### new EventBus()

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.

Source:
  - vertx-js/event_bus.js, line 42

### Methods

#### addInterceptor(interceptor) → {EventBus}

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

##### Parameters:

Name | Type | Description
--- | --- | ---
`interceptor` | function | the interceptor

Source:
  - vertx-js/event_bus.js, line 203

##### Returns:

a reference to this, so the API can be used fluently

Type
  EventBus

#### consumer(address, handler) → {MessageConsumer}

Create a consumer and register it against the specified address.

##### Parameters:

Name | Type | Description
--- | --- | ---
`address` | string | the address that will register it at
`handler` | function | the handler that will process the received messages

Source:
  - vertx-js/event_bus.js, line 130

##### Returns:

the event bus message consumer

Type
  MessageConsumer

#### isMetricsEnabled() → {boolean}

Whether the metrics are enabled for this measured object

Source:
  - vertx-js/event_bus.js, line 55

##### Returns:

true if the metrics are enabled

Type
  boolean

#### localConsumer(address, handler) → {MessageConsumer}

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

##### Parameters:

Name | Type | Description
--- | --- | ---
`address` | string | the address that will register it at
`handler` | function | the handler that will process the received messages

Source:
  - vertx-js/event_bus.js, line 149

##### Returns:

the event bus message consumer

Type
  MessageConsumer

#### publish(address, message, options) → {EventBus}

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

##### Parameters:

Name | Type | Description
--- | --- | ---
`address` | string | the address to publish it to
`message` | Object | the message, may be `null`
`options` | Object | the delivery options

Source:
  - vertx-js/event_bus.js, line 111

##### Returns:

a reference to this, so the API can be used fluently

Type
  EventBus

#### publisher(address, options) → {MessageProducer}

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

##### Parameters:

Name | Type | Description
--- | --- | ---
`address` | string | the address to publish it to
`options` | Object | the delivery options

Source:
  - vertx-js/event_bus.js, line 187

##### Returns:

The publisher

Type
  MessageProducer

#### removeInterceptor(interceptor) → {EventBus}

Remove an interceptor

##### Parameters:

Name | Type | Description
--- | --- | ---
`interceptor` | function | the interceptor

Source:
  - vertx-js/event_bus.js, line 219

##### Returns:

a reference to this, so the API can be used fluently

Type
  EventBus

#### send(address, message, options, replyHandler) → {EventBus}

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

##### Parameters:

Name | Type | Description
--- | --- | ---
`address` | string | the address to send it to
`message` | Object | the message, may be `null`
`options` | Object | delivery options
`replyHandler` | function | reply handler will be called when any reply from the recipient is received, may be `null`

Source:
  - vertx-js/event_bus.js, line 73

##### Returns:

a reference to this, so the API can be used fluently

Type
  EventBus

#### sender(address, options) → {MessageProducer}

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

##### Parameters:

Name | Type | Description
--- | --- | ---
`address` | string | the address to send it to
`options` | Object | the delivery options

Source:
  - vertx-js/event_bus.js, line 169

##### Returns:

The sender

Type
  MessageProducer