@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 and description |
---|
EventBus
(java.lang.Object delegate) |
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. |
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() |
Add an interceptor that will be called whenever a message is sent from Vert.x
interceptor
- the interceptorCreate 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.
address
- the address that it will register it atCreate a consumer and register it against the specified address.
address
- the address that will register it athandler
- the handler that will process the received messagesWhether the metrics are enabled for this measured object
Like EventBus.consumer but the address won't be propagated across the cluster.
address
- the address to register it atLike EventBus.consumer but the address won't be propagated across the cluster.
address
- the address that will register it athandler
- the handler that will process the received messagesPublish a message.
The message will be delivered to all handlers registered to the address.
address
- the address to publish it tomessage
- the message, may be null
Like EventBus.publish but specifying options
that can be used to configure the delivery.
address
- the address to publish it tomessage
- the message, may be null
options
- the delivery options (see DeliveryOptions)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.
address
- The address to publish it toLike EventBus.publisher but specifying delivery options that will be used for configuring the delivery of the message.
address
- the address to publish it tooptions
- the delivery options (see DeliveryOptions)Remove an interceptor
interceptor
- the interceptorSends a message.
The message will be delivered to at most one of the handlers registered to the address.
address
- the address to send it tomessage
- the message, may be null
Like EventBus.send but specifying a replyHandler
that will be called if the recipient
subsequently replies to the message.
address
- the address to send it tomessage
- the message, may be null
replyHandler
- reply handler will be called when any reply from the recipient is received, may be null
Like EventBus.send but specifying options
that can be used to configure the delivery.
address
- the address to send it tomessage
- the message, may be null
options
- delivery options (see DeliveryOptions) Like EventBus.send but specifying a replyHandler
that will be called if the recipient
subsequently replies to the message.
address
- the address to send it tomessage
- 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
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.
address
- the address to send it toLike EventBus.sender but specifying delivery options that will be used for configuring the delivery of the message.
address
- the address to send it tooptions
- the delivery options (see DeliveryOptions)