A distributed lightweight event bus which can encompass multiple vert.x instances.
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.
Represents a message on the event bus.
Represents a message on the event bus.
Instances of this class are not thread-safe
A RegisteredHandler can be unregistered at a later point in time.
Companion object for EventBus.
Companion object for Message.