public class EventBusImpl extends Object implements EventBusInternal, MetricsProvider
| 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> HandlerHolder<T> |
addRegistration(String address,
HandlerRegistration<T> registration,
boolean replyHandler,
boolean localOnly,
Promise<Void> promise) |
protected void |
callCompletionHandlerAsync(Handler<AsyncResult<Void>> completionHandler) |
protected void |
checkStarted() |
void |
close(Promise<Void> promise)
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> HandlerHolder<T> |
createHandlerHolder(HandlerRegistration<T> registration,
boolean replyHandler,
boolean localOnly,
ContextInternal context) |
MessageImpl |
createMessage(boolean send,
String address,
MultiMap headers,
Object body,
String codecName) |
protected ReplyException |
deliverMessageLocally(MessageImpl msg) |
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. |
<T> OutboundDeliveryContext<T> |
newSendContext(MessageImpl message,
DeliveryOptions options,
io.vertx.core.eventbus.impl.ReplyHandler<T> handler,
Promise<Void> writePromise) |
protected <T> void |
onLocalRegistration(HandlerHolder<T> handlerHolder,
Promise<Void> promise) |
protected <T> void |
onLocalUnregistration(HandlerHolder<T> handlerHolder,
Promise<Void> promise) |
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> handlerHolder,
Promise<Void> promise) |
<T> Future<Message<T>> |
request(String address,
Object message,
DeliveryOptions options)
Like
EventBus.request(String, Object, DeliveryOptions, Handler) but returns a Future of the asynchronous result |
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> 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(OutboundDeliveryContext<T> sendContext) |
<T> void |
sendOrPubInternal(MessageImpl message,
DeliveryOptions options,
io.vertx.core.eventbus.impl.ReplyHandler<T> handler,
Promise<Void> writePromise) |
<T> void |
sendOrPubInternal(OutboundDeliveryContext<T> senderCtx) |
protected <T> void |
sendReply(MessageImpl replyMessage,
DeliveryOptions options,
io.vertx.core.eventbus.impl.ReplyHandler<T> replyHandler) |
void |
start(Promise<Void> promise)
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(Promise<Void> promise)
EventBusInternalstart in interface EventBusInternalpublic EventBus send(String address, Object message)
EventBusThe message will be delivered to at most one of the handlers registered to the address.
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> Future<Message<T>> request(String address, Object message, DeliveryOptions options)
EventBusEventBus.request(String, Object, DeliveryOptions, Handler) but returns a Future of the asynchronous resultpublic <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(Promise<Void> promise)
EventBusInternalclose in interface EventBusInternalpublic 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)
protected <T> HandlerHolder<T> addRegistration(String address, HandlerRegistration<T> registration, boolean replyHandler, boolean localOnly, Promise<Void> promise)
protected <T> void onLocalRegistration(HandlerHolder<T> handlerHolder, Promise<Void> promise)
protected <T> HandlerHolder<T> createHandlerHolder(HandlerRegistration<T> registration, boolean replyHandler, boolean localOnly, ContextInternal context)
protected <T> void removeRegistration(HandlerHolder<T> handlerHolder, Promise<Void> promise)
protected <T> void onLocalUnregistration(HandlerHolder<T> handlerHolder, Promise<Void> promise)
protected <T> void sendReply(MessageImpl replyMessage, DeliveryOptions options, io.vertx.core.eventbus.impl.ReplyHandler<T> replyHandler)
protected <T> void sendOrPub(OutboundDeliveryContext<T> sendContext)
protected void callCompletionHandlerAsync(Handler<AsyncResult<Void>> completionHandler)
protected boolean isMessageLocal(MessageImpl msg)
protected ReplyException deliverMessageLocally(MessageImpl msg)
protected void checkStarted()
protected String generateReplyAddress()
public <T> OutboundDeliveryContext<T> newSendContext(MessageImpl message, DeliveryOptions options, io.vertx.core.eventbus.impl.ReplyHandler<T> handler, Promise<Void> writePromise)
public <T> void sendOrPubInternal(OutboundDeliveryContext<T> senderCtx)
public <T> void sendOrPubInternal(MessageImpl message, DeliveryOptions options, io.vertx.core.eventbus.impl.ReplyHandler<T> handler, Promise<Void> writePromise)
Copyright © 2021. All rights reserved.