Options
All
  • Public
  • Public/Protected
  • All
Menu

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

Hierarchy

  • EventBus

Implements

Index

Methods

addInboundInterceptor

  • Add an interceptor that will be called whenever a message is received by Vert.x

    Type parameters

    • T

    Parameters

    Returns EventBus

addOutboundInterceptor

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

    Type parameters

    • T

    Parameters

    Returns EventBus

clusterSerializableChecker

  • clusterSerializableChecker(classNamePredicate: (arg: string) => boolean): EventBus
  • Register a predicate to invoke when verifying if an object is forbidden to be encoded/decoded as {@link ClusterSerializable}.

    This is only used when Vert.x is clustered.

    Parameters

    • classNamePredicate: (arg: string) => boolean
        • (arg: string): boolean
        • Parameters

          • arg: string

          Returns boolean

    Returns EventBus

codecSelector

  • codecSelector(selector: (arg: any) => string): EventBus
  • Set selector to be invoked when the bus has not found any codec for a Message body.

    The selector must return the name of a codec which has been registered with either {@link EventBus#registerCodec} or {@link EventBus#registerDefaultCodec}.

    Parameters

    • selector: (arg: any) => string
        • (arg: any): string
        • Parameters

          • arg: any

          Returns string

    Returns EventBus

consumer

  • Create a message consumer against the specified address.

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

    Type parameters

    • T

    Parameters

    • address: string

    Returns MessageConsumer<T>

  • Create a consumer and register it against the specified address.

    Type parameters

    • T

    Parameters

    Returns MessageConsumer<T>

isMetricsEnabled

  • isMetricsEnabled(): boolean
  • Whether the metrics are enabled for this measured object

    Returns boolean

localConsumer

  • Like {@link EventBus#consumer} but the address won't be propagated across the cluster.

    Type parameters

    • T

    Parameters

    • address: string

    Returns MessageConsumer<T>

  • Like {@link EventBus#consumer} but the address won't be propagated across the cluster.

    Type parameters

    • T

    Parameters

    Returns MessageConsumer<T>

publish

  • publish(address: string, message: any | null | undefined): EventBus
  • publish(address: string, message: any | null | undefined, options: DeliveryOptions): EventBus
  • Publish a message.

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

    Parameters

    • address: string
    • message: any | null | undefined

    Returns EventBus

  • Like {@link EventBus#publish} but specifying options that can be used to configure the delivery.

    Parameters

    Returns EventBus

publisher

  • Create a message publisher against the specified address.

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

    Type parameters

    • T

    Parameters

    • address: string

    Returns MessageProducer<T>

  • Like {@link EventBus#publisher} but specifying delivery options that will be used for configuring the delivery of the message.

    Type parameters

    • T

    Parameters

    Returns MessageProducer<T>

registerCodec

  • Register a message codec.

    You can register a message codec if you want to send any non standard message across the event bus. E.g. you might want to send POJOs directly across the event bus.

    To use a message codec for a send, you should specify it in the delivery options.

    Parameters

    • codec: any

    Returns EventBus

removeInboundInterceptor

  • Remove an interceptor that was added by {@link EventBus#addInboundInterceptor}

    Type parameters

    • T

    Parameters

    Returns EventBus

removeOutboundInterceptor

  • Remove an interceptor that was added by {@link EventBus#addOutboundInterceptor}

    Type parameters

    • T

    Parameters

    Returns EventBus

request

  • Sends a message and specify a replyHandler that will be called if the recipient subsequently replies to the message.

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

    Type parameters

    • T

    Parameters

    • address: string
    • message: any | null | undefined

    Returns PromiseLike<Message<T>>

  • Sends a message and specify a replyHandler that will be called if the recipient subsequently replies to the message.

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

    Type parameters

    • T

    Parameters

    Returns EventBus

  • Like {@link EventBus#request} but specifying options that can be used to configure the delivery.

    Type parameters

    • T

    Parameters

    Returns PromiseLike<Message<T>>

  • Like {@link EventBus#request} but specifying options that can be used to configure the delivery.

    Type parameters

    • T

    Parameters

    Returns EventBus

send

  • send(address: string, message: any | null | undefined): EventBus
  • send(address: string, message: any | null | undefined, options: DeliveryOptions): EventBus
  • Sends a message.

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

    Parameters

    • address: string
    • message: any | null | undefined

    Returns EventBus

  • Like {@link EventBus#send} but specifying options that can be used to configure the delivery.

    Parameters

    Returns EventBus

sender

  • Create a message sender against the specified address.

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

    Type parameters

    • T

    Parameters

    • address: string

    Returns MessageProducer<T>

  • Like {@link EventBus#sender} but specifying delivery options that will be used for configuring the delivery of the message.

    Type parameters

    • T

    Parameters

    Returns MessageProducer<T>

serializableChecker

  • serializableChecker(classNamePredicate: (arg: string) => boolean): EventBus
  • Register a predicate to invoke when verifying if an object is allowed to be encoded/decoded as Serializable.

    This is only used when Vert.x is clustered.

    Parameters

    • classNamePredicate: (arg: string) => boolean
        • (arg: string): boolean
        • Parameters

          • arg: string

          Returns boolean

    Returns EventBus

unregisterCodec

  • unregisterCodec(name: string): EventBus
  • Unregister a message codec.

    Parameters

    • name: string

    Returns EventBus

Generated using TypeDoc