org.vertx.scala.core.eventbus

EventBus

final class EventBus extends Self

A distributed lightweight event bus which can encompass multiple vert.x instances. The event bus implements publish / subscribe, point to point messaging and request-response messaging.

Messages sent over the event bus are represented by instances of the org.vertx.scala.core.eventbus.Message class.

For publish / subscribe, messages can be published to an address using one of the publish methods. An address is a simple java.lang.String instance.

Handlers are registered against an address. There can be multiple handlers registered against each address, and a particular handler can be registered against multiple addresses. The event bus will route a sent message to all handlers which are registered against that address.

For point to point messaging, messages can be sent to an address using one of the send methods. The messages will be delivered to a single handler, if one is registered on that address. If more than one handler is registered on the same address, Vert.x will choose one and deliver the message to that. Vert.x will aim to fairly distribute messages in a round-robin way, but does not guarantee strict round-robin under all circumstances.

All messages sent over the bus are transient. On event of failure of all or part of the event bus messages may be lost. Applications should be coded to cope with lost messages, e.g. by resending them, and making application services idempotent.

The order of messages received by any specific handler from a specific sender should match the order of messages sent from that sender.

When sending a message, a reply handler can be provided. If so, it will be called when the reply from the receiver has been received. Reply messages can also be replied to, etc, ad infinitum

Different event bus instances can be clustered together over a network, to give a single logical event bus.

Instances of EventBus are thread-safe.

If handlers are registered from an event loop, they will be executed using that same event loop. If they are registered from outside an event loop (i.e. when using Vert.x embedded) then Vert.x will assign an event loop to the handler and use it to deliver messages to that handler.

Linear Supertypes
Self, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. EventBus
  2. Self
  3. AnyRef
  4. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  5. val asJava: java.core.eventbus.EventBus

  6. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. def close(doneHandler: (AsyncResult[Void]) ⇒ Unit): Unit

    Close the EventBus and release all resources.

    Close the EventBus and release all resources.

    doneHandler

    handler to notify when close is completed

  8. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  9. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  10. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  11. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  12. def getDefaultReplyTimeout: Long

    Return the value for default send timeout.

  13. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  14. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  15. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  16. final def notify(): Unit

    Definition Classes
    AnyRef
  17. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  18. def publish[T](address: String, message: T)(implicit arg0: (T) ⇒ MessageData): EventBus

    Publish a message.

    Publish a message.

    address

    The address to publish it to

    message

    The message

  19. def registerHandler[T](address: String, handler: (Message[T]) ⇒ Unit, resultHandler: (AsyncResult[Void]) ⇒ Unit)(implicit arg0: (T) ⇒ MessageData): RegisteredHandler[T]

    Registers a handler against the specified address.

    Registers a handler against the specified address. To unregister this handler, use the resulting RegisteredHandler object.

    address

    The address to register it at.

    handler

    The handler.

    resultHandler

    Optional completion handler. If specified, when the register has been propagated to all nodes of the event bus, the handler will be called.

  20. def registerHandler[T](address: String, handler: (Message[T]) ⇒ Unit)(implicit arg0: (T) ⇒ MessageData): RegisteredHandler[T]

    Registers a handler against the specified address.

    Registers a handler against the specified address. To unregister this handler, use the resulting RegisteredHandler object.

    address

    The address to register it at.

    handler

    The handler.

  21. def registerLocalHandler[T](address: String, handler: (Message[T]) ⇒ Unit)(implicit arg0: (T) ⇒ MessageData): RegisteredHandler[T]

    Registers a local handler against the specified address.

    Registers a local handler against the specified address. The handler info won't be propagated across the cluster. To unregister this handler, use the resulting RegisteredHandler object.

    address

    The address to register it at.

    handler

    The handler to register.

  22. def send[ST, RT](address: String, message: ST, replyHandler: (Message[RT]) ⇒ Unit)(implicit arg0: (ST) ⇒ MessageData, arg1: (RT) ⇒ MessageData): EventBus

    Send a message.

    Send a message.

    address

    The address to send it to

    message

    The message

    replyHandler

    Reply handler will be called when any reply from the recipient is received

  23. def send[T](address: String, message: T)(implicit arg0: (T) ⇒ MessageData): EventBus

    Send a message.

    Send a message.

    address

    The address to send it to

    message

    The message

  24. def sendWithTimeout[ST, RT](address: String, message: ST, timeout: Long, replyHandler: (AsyncResult[Message[RT]]) ⇒ Unit)(implicit arg0: (ST) ⇒ MessageData, arg1: (RT) ⇒ MessageData): EventBus

    Send a character as a message

    Send a character as a message

    address

    The address to send it to

    message

    The message

    timeout

    - Timeout in ms. If no reply received within the timeout then the reply handler will be unregistered

    replyHandler

    Reply handler will be called when any reply from the recipient is received

  25. def setDefaultReplyTimeout(timeoutMs: Long): EventBus

    Sets a default timeout, in ms, for replies.

    Sets a default timeout, in ms, for replies. If a messages is sent specify a reply handler but without specifying a timeout, then the reply handler is timed out, i.e. it is automatically unregistered if a message hasn't been received before timeout. The default value for default send timeout is -1, which means "never timeout".

    timeoutMs

    timeout in milliseconds

  26. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  27. def toString(): String

    Definition Classes
    AnyRef → Any
  28. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  29. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  30. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  31. def wrap[X](doStuff: ⇒ X): EventBus.this.type

    Helper method wrapping invocations and returning the Scala type, once again to help provide fluent return types

    Helper method wrapping invocations and returning the Scala type, once again to help provide fluent return types

    Attributes
    protected[this]
    Definition Classes
    Self

Inherited from Self

Inherited from AnyRef

Inherited from Any

Ungrouped