public class EventBusImpl extends Object implements EventBus, MetricsProvider
| Modifier and Type | Class and Description |
|---|---|
class |
EventBusImpl.HandlerEntry<T> |
protected class |
EventBusImpl.InboundDeliveryContext<T> |
protected class |
EventBusImpl.OutboundDeliveryContext<T> |
| Modifier and Type | Field and Description |
|---|---|
protected CodecManager |
codecManager |
protected ConcurrentMap<String,ConcurrentCyclicSequence<HandlerHolder>> |
handlerMap |
protected EventBusMetrics |
metrics |
protected boolean |
started |
protected VertxInternal |
vertx |
| Constructor and Description |
|---|
EventBusImpl(VertxInternal vertx) |
| Modifier and Type | Method and Description |
|---|---|
<T> EventBus |
addInboundInterceptor(Handler<DeliveryContext<T>> interceptor)
Add an interceptor that will be called whenever a message is received by Vert.x
|
<T> EventBus |
addOutboundInterceptor(Handler<DeliveryContext<T>> interceptor)
Add an interceptor that will be called whenever a message is sent from Vert.x
|
protected <T> void |
addRegistration(boolean newAddress,
String address,
boolean replyHandler,
boolean localOnly,
Handler<AsyncResult<Void>> completionHandler) |
protected <T> HandlerHolder<T> |
addRegistration(String address,
HandlerRegistration<T> registration,
boolean replyHandler,
boolean localOnly) |
protected void |
callCompletionHandlerAsync(Handler<AsyncResult<Void>> completionHandler) |
protected void |
checkStarted() |
void |
close(Handler<AsyncResult<Void>> completionHandler)
Close the event bus and release any resources held.
|
<T> MessageConsumer<T> |
consumer(String address)
Create a message consumer against the specified address.
|
<T> MessageConsumer<T> |
consumer(String address,
Handler<Message<T>> handler)
Create a consumer and register it against the specified address.
|
protected <T> Handler<Message<T>> |
convertHandler(Handler<AsyncResult<Message<T>>> handler) |
MessageImpl |
createMessage(boolean send,
String address,
MultiMap headers,
Object body,
String codecName,
Handler<AsyncResult<Void>> writeHandler) |
protected <T> void |
deliverMessageLocally(EventBusImpl.OutboundDeliveryContext<T> sendContext) |
protected ReplyException |
deliverMessageLocally(MessageImpl msg) |
protected void |
finalize() |
protected String |
generateReplyAddress() |
EventBusMetrics<?> |
getMetrics()
Returns the metrics implementation.
|
protected boolean |
isMessageLocal(MessageImpl msg) |
boolean |
isMetricsEnabled()
Whether the metrics are enabled for this measured object
|
<T> MessageConsumer<T> |
localConsumer(String address)
Like
EventBus.consumer(String) but the address won't be propagated across the cluster. |
<T> MessageConsumer<T> |
localConsumer(String address,
Handler<Message<T>> handler)
Like
EventBus.consumer(String, Handler) but the address won't be propagated across the cluster. |
EventBus |
publish(String address,
Object message)
Publish a message.
|
EventBus |
publish(String address,
Object message,
DeliveryOptions options)
Like
EventBus.publish(String, Object) but specifying options that can be used to configure the delivery. |
<T> MessageProducer<T> |
publisher(String address)
Create a message publisher against the specified address.
|
<T> MessageProducer<T> |
publisher(String address,
DeliveryOptions options)
Like
EventBus.publisher(String) but specifying delivery options that will be used for configuring the delivery of
the message. |
EventBus |
registerCodec(MessageCodec codec)
Register a message codec.
|
<T> EventBus |
registerDefaultCodec(Class<T> clazz,
MessageCodec<T,?> codec)
Register a default message codec.
|
<T> EventBus |
removeInboundInterceptor(Handler<DeliveryContext<T>> interceptor)
Remove an interceptor that was added by
EventBus.addInboundInterceptor(Handler) |
<T> EventBus |
removeOutboundInterceptor(Handler<DeliveryContext<T>> interceptor)
Remove an interceptor that was added by
EventBus.addOutboundInterceptor(Handler) |
protected <T> void |
removeRegistration(HandlerHolder<T> holder,
Handler<AsyncResult<Void>> completionHandler) |
protected <T> void |
removeRegistration(HandlerHolder<T> handlerHolder,
String address,
Handler<AsyncResult<Void>> completionHandler) |
EventBus |
send(String address,
Object message)
Sends a message.
|
EventBus |
send(String address,
Object message,
DeliveryOptions options)
Like
EventBus.send(String, Object) but specifying options that can be used to configure the delivery. |
<T> EventBus |
send(String address,
Object message,
DeliveryOptions options,
Handler<AsyncResult<Message<T>>> replyHandler)
Like
EventBus.send(String, Object, DeliveryOptions) but specifying a replyHandler that will be called if the recipient
subsequently replies to the message. |
<T> EventBus |
send(String address,
Object message,
Handler<AsyncResult<Message<T>>> replyHandler)
Like
EventBus.send(String, Object) but specifying a replyHandler that will be called if the recipient
subsequently replies to the message. |
<T> MessageProducer<T> |
sender(String address)
Create a message sender against the specified address.
|
<T> MessageProducer<T> |
sender(String address,
DeliveryOptions options)
Like
EventBus.sender(String) but specifying delivery options that will be used for configuring the delivery of
the message. |
protected <T> void |
sendOrPub(EventBusImpl.OutboundDeliveryContext<T> sendContext) |
<T> void |
sendOrPubInternal(MessageImpl message,
DeliveryOptions options,
Handler<AsyncResult<Message<T>>> replyHandler) |
protected <T> void |
sendReply(EventBusImpl.OutboundDeliveryContext<T> sendContext,
MessageImpl replierMessage) |
protected <T> void |
sendReply(MessageImpl replyMessage,
MessageImpl replierMessage,
DeliveryOptions options,
Handler<AsyncResult<Message<T>>> replyHandler) |
void |
start(Handler<AsyncResult<Void>> completionHandler)
Start the event bus.
|
EventBus |
unregisterCodec(String name)
Unregister a message codec.
|
EventBus |
unregisterDefaultCodec(Class clazz)
Unregister a default message codec.
|
protected final VertxInternal vertx
protected final EventBusMetrics metrics
protected final ConcurrentMap<String,ConcurrentCyclicSequence<HandlerHolder>> handlerMap
protected final CodecManager codecManager
protected volatile boolean started
public EventBusImpl(VertxInternal vertx)
public <T> EventBus addOutboundInterceptor(Handler<DeliveryContext<T>> interceptor)
EventBusaddOutboundInterceptor in interface EventBusinterceptor - the interceptorpublic <T> EventBus addInboundInterceptor(Handler<DeliveryContext<T>> interceptor)
EventBusaddInboundInterceptor in interface EventBusinterceptor - the interceptorpublic <T> EventBus removeOutboundInterceptor(Handler<DeliveryContext<T>> interceptor)
EventBusEventBus.addOutboundInterceptor(Handler)removeOutboundInterceptor in interface EventBusinterceptor - the interceptorpublic <T> EventBus removeInboundInterceptor(Handler<DeliveryContext<T>> interceptor)
EventBusEventBus.addInboundInterceptor(Handler)removeInboundInterceptor in interface EventBusinterceptor - the interceptorpublic void start(Handler<AsyncResult<Void>> completionHandler)
EventBuspublic EventBus send(String address, Object message)
EventBusThe message will be delivered to at most one of the handlers registered to the address.
public <T> EventBus send(String address, Object message, Handler<AsyncResult<Message<T>>> replyHandler)
EventBusEventBus.send(String, Object) but specifying a replyHandler that will be called if the recipient
subsequently replies to the message.public EventBus send(String address, Object message, DeliveryOptions options)
EventBusEventBus.send(String, Object) but specifying options that can be used to configure the delivery.public <T> EventBus send(String address, Object message, DeliveryOptions options, Handler<AsyncResult<Message<T>>> replyHandler)
EventBusEventBus.send(String, Object, DeliveryOptions) but specifying a replyHandler that will be called if the recipient
subsequently replies to the message.send in interface EventBusaddress - the address to send it tomessage - the message, may be nulloptions - delivery optionsreplyHandler - reply handler will be called when any reply from the recipient is received, may be nullpublic <T> MessageProducer<T> sender(String address)
EventBus
The returned sender will invoke the EventBus.send(String, Object)
method when the stream WriteStream.write(Object) method is called with the sender
address and the provided data.
public <T> MessageProducer<T> sender(String address, DeliveryOptions options)
EventBusEventBus.sender(String) but specifying delivery options that will be used for configuring the delivery of
the message.public <T> MessageProducer<T> publisher(String address)
EventBus
The returned publisher will invoke the EventBus.publish(String, Object)
method when the stream WriteStream.write(Object) method is called with the publisher
address and the provided data.
public <T> MessageProducer<T> publisher(String address, DeliveryOptions options)
EventBusEventBus.publisher(String) but specifying delivery options that will be used for configuring the delivery of
the message.public EventBus publish(String address, Object message)
EventBusThe message will be delivered to all handlers registered to the address.
public EventBus publish(String address, Object message, DeliveryOptions options)
EventBusEventBus.publish(String, Object) but specifying options that can be used to configure the delivery.public <T> MessageConsumer<T> consumer(String address)
EventBus
The returned consumer is not yet registered
at the address, registration will be effective when MessageConsumer.handler(io.vertx.core.Handler)
is called.
public <T> MessageConsumer<T> consumer(String address, Handler<Message<T>> handler)
EventBuspublic <T> MessageConsumer<T> localConsumer(String address)
EventBusEventBus.consumer(String) but the address won't be propagated across the cluster.localConsumer in interface EventBusaddress - the address to register it atpublic <T> MessageConsumer<T> localConsumer(String address, Handler<Message<T>> handler)
EventBusEventBus.consumer(String, Handler) but the address won't be propagated across the cluster.localConsumer in interface EventBusaddress - the address that will register it athandler - the handler that will process the received messagespublic EventBus registerCodec(MessageCodec codec)
EventBusYou 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.
registerCodec in interface EventBuscodec - the message codec to registerpublic EventBus unregisterCodec(String name)
EventBusunregisterCodec in interface EventBusname - the name of the codecpublic <T> EventBus registerDefaultCodec(Class<T> clazz, MessageCodec<T,?> codec)
EventBusYou 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.
Default message codecs will be used to serialise any messages of the specified type on the event bus without the codec having to be specified in the delivery options.
registerDefaultCodec in interface EventBusclazz - the class for which to use this codeccodec - the message codec to registerpublic EventBus unregisterDefaultCodec(Class clazz)
EventBusunregisterDefaultCodec in interface EventBusclazz - the class for which the codec was registeredpublic void close(Handler<AsyncResult<Void>> completionHandler)
EventBuspublic boolean isMetricsEnabled()
MeasuredisMetricsEnabled in interface Measuredtrue if metrics are enabledpublic EventBusMetrics<?> getMetrics()
MetricsProvidergetMetrics in interface MetricsProviderpublic MessageImpl createMessage(boolean send, String address, MultiMap headers, Object body, String codecName, Handler<AsyncResult<Void>> writeHandler)
protected <T> HandlerHolder<T> addRegistration(String address, HandlerRegistration<T> registration, boolean replyHandler, boolean localOnly)
protected <T> void addRegistration(boolean newAddress,
String address,
boolean replyHandler,
boolean localOnly,
Handler<AsyncResult<Void>> completionHandler)
protected <T> void removeRegistration(HandlerHolder<T> holder, Handler<AsyncResult<Void>> completionHandler)
protected <T> void removeRegistration(HandlerHolder<T> handlerHolder, String address, Handler<AsyncResult<Void>> completionHandler)
protected <T> void sendReply(MessageImpl replyMessage, MessageImpl replierMessage, DeliveryOptions options, Handler<AsyncResult<Message<T>>> replyHandler)
protected <T> void sendReply(EventBusImpl.OutboundDeliveryContext<T> sendContext, MessageImpl replierMessage)
protected <T> void sendOrPub(EventBusImpl.OutboundDeliveryContext<T> sendContext)
protected <T> Handler<Message<T>> convertHandler(Handler<AsyncResult<Message<T>>> handler)
protected void callCompletionHandlerAsync(Handler<AsyncResult<Void>> completionHandler)
protected <T> void deliverMessageLocally(EventBusImpl.OutboundDeliveryContext<T> sendContext)
protected boolean isMessageLocal(MessageImpl msg)
protected ReplyException deliverMessageLocally(MessageImpl msg)
protected void checkStarted()
protected String generateReplyAddress()
public <T> void sendOrPubInternal(MessageImpl message, DeliveryOptions options, Handler<AsyncResult<Message<T>>> replyHandler)
Copyright © 2020. All rights reserved.