Class EventBus
- All Implemented Interfaces:
MutinyDelegate,Measured
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.
NOTE: This class has been automatically generated from the original non Mutiny-ified interface.
- Author:
- Tim Fox
- See Also:
-
EventBus
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.vertx.mutiny.core.metrics.Measured
Measured.MeasuredImpl -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> EventBusaddInboundInterceptor(Consumer<DeliveryContext<T>> interceptor) Add an interceptor that will be called whenever a message is received by Vert.x<T> EventBusaddOutboundInterceptor(Consumer<DeliveryContext<T>> interceptor) Add an interceptor that will be called whenever a message is sent from Vert.xclusterSerializableChecker(Function<String, Boolean> classNamePredicate) Register a predicate to invoke when verifying if an object is forbidden to be encoded/decoded asClusterSerializable.codecSelector(Function<Object, String> selector) Set selector to be invoked when the bus has not found any codec for aMessagebody.<T> MessageConsumer<T>consumer(io.vertx.core.eventbus.MessageConsumerOptions options) Create a message consumer against the specified options address.<T> MessageConsumer<T>Create a consumer and register it against the specified options address.<T> MessageConsumer<T>Create a message consumer against the specified address.<T> MessageConsumer<T>Create a consumer and register it against the specified address.booleanio.vertx.core.eventbus.EventBusGet the delegate instance.inthashCode()booleanWhether the metrics are enabled for this measured object<T> MessageConsumer<T>localConsumer(String address) Likeconsumer(String)but the address won't be propagated across the cluster.<T> MessageConsumer<T>localConsumer(String address, Consumer<Message<T>> handler) Like#consumer(String, Handler)but the address won't be propagated across the cluster.static EventBusnewInstance(io.vertx.core.eventbus.EventBus delegate) Creates a new instance of theEventBus.Publish a message.Likepublish(String, Object)but specifyingoptionsthat can be used to configure the delivery.<T> MessageProducer<T>Create a message publisher against the specified address.<T> MessageProducer<T>Likepublisher(String)but specifying delivery options that will be used for configuring the delivery of the message.registerCodec(io.vertx.core.eventbus.MessageCodec codec) Register a message codec.<T> EventBusremoveInboundInterceptor(Consumer<DeliveryContext<T>> interceptor) Remove an interceptor that was added by#addInboundInterceptor(Handler)<T> EventBusremoveOutboundInterceptor(Consumer<DeliveryContext<T>> interceptor) Remove an interceptor that was added by#addOutboundInterceptor(Handler)<T> io.smallrye.mutiny.Uni<Message<T>>Sends a message and specify areplyHandlerthat will be called if the recipient subsequently replies to the message.<T> io.smallrye.mutiny.Uni<Message<T>>Likerequest(String, Object)but specifyingoptionsthat can be used to configure the delivery.<T> Message<T>requestAndAwait(String address, Object message) Sends a message and specify areplyHandlerthat will be called if the recipient subsequently replies to the message.<T> Message<T>requestAndAwait(String address, Object message, io.vertx.core.eventbus.DeliveryOptions options) Likerequest(String, Object)but specifyingoptionsthat can be used to configure the delivery.<T> EventBusrequestAndForget(String address, Object message) Sends a message and specify areplyHandlerthat will be called if the recipient subsequently replies to the message.<T> EventBusrequestAndForget(String address, Object message, io.vertx.core.eventbus.DeliveryOptions options) Likerequest(String, Object)but specifyingoptionsthat can be used to configure the delivery.Sends a message.Likesend(String, Object)but specifyingoptionsthat can be used to configure the delivery.<T> MessageProducer<T>Create a message sender against the specified address.<T> MessageProducer<T>Likesender(String)but specifying delivery options that will be used for configuring the delivery of the message.serializableChecker(Function<String, Boolean> classNamePredicate) Register a predicate to invoke when verifying if an object is allowed to be encoded/decoded asSerializable.toString()unregisterCodec(String name) Unregister a message codec.
-
Field Details
-
__TYPE_ARG
-
-
Constructor Details
-
EventBus
public EventBus(io.vertx.core.eventbus.EventBus delegate) Create a new instance ofEventBusdelegating to the given (non-null) instance ofEventBus. -
EventBus
-
-
Method Details
-
getDelegate
public io.vertx.core.eventbus.EventBus getDelegate()Get the delegate instance.This method returns the instance on which this shim is delegating the calls. And so, give you access to the bare API.
- Specified by:
getDelegatein interfaceMeasured- Specified by:
getDelegatein interfaceMutinyDelegate- Returns:
- the delegate instance
-
request
@CheckReturnValue public <T> io.smallrye.mutiny.Uni<Message<T>> request(String address, Object message) Sends a message and specify areplyHandlerthat will be called if the recipient subsequently replies to the message.The message will be delivered to at most one of the handlers registered to the address.
Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Parameters:
address- the address to send it tomessage- the message body, may benull- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
EventBus.request(String, Object)
-
requestAndAwait
Sends a message and specify areplyHandlerthat will be called if the recipient subsequently replies to the message.The message will be delivered to at most one of the handlers registered to the address.
Unlike the bare Vert.x variant, this method returns a
Message<T>. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- Parameters:
address- the address to send it tomessage- the message body, may benull- Returns:
- The operation result
- See Also:
-
EventBus.request(String, Object)
-
requestAndForget
Sends a message and specify areplyHandlerthat will be called if the recipient subsequently replies to the message.The message will be delivered to at most one of the handlers registered to the address.
Unlike the bare Vert.x variant, this method ignores the
Message<T>result or any failure.- Parameters:
address- the address to send it tomessage- the message body, may benull- Returns:
- The current instance to chain operations if needed.
- See Also:
-
EventBus.request(String, Object)
-
request
@CheckReturnValue public <T> io.smallrye.mutiny.Uni<Message<T>> request(String address, Object message, io.vertx.core.eventbus.DeliveryOptions options) Likerequest(String, Object)but specifyingoptionsthat can be used to configure the delivery.Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Parameters:
address- the address to send it tomessage- the message body, may benulloptions- delivery options- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
EventBus.request(String, Object, DeliveryOptions)
-
requestAndAwait
public <T> Message<T> requestAndAwait(String address, Object message, io.vertx.core.eventbus.DeliveryOptions options) Likerequest(String, Object)but specifyingoptionsthat can be used to configure the delivery.Unlike the bare Vert.x variant, this method returns a
Message<T>. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- Parameters:
address- the address to send it tomessage- the message body, may benulloptions- delivery options- Returns:
- The operation result
- See Also:
-
EventBus.request(String, Object, DeliveryOptions)
-
requestAndForget
public <T> EventBus requestAndForget(String address, Object message, io.vertx.core.eventbus.DeliveryOptions options) Likerequest(String, Object)but specifyingoptionsthat can be used to configure the delivery.Unlike the bare Vert.x variant, this method ignores the
Message<T>result or any failure.- Parameters:
address- the address to send it tomessage- the message body, may benulloptions- delivery options- Returns:
- The current instance to chain operations if needed.
- See Also:
-
EventBus.request(String, Object, DeliveryOptions)
-
send
Sends a message.The message will be delivered to at most one of the handlers registered to the address.
- Parameters:
address- the address to send it tomessage- the message, may benull- Returns:
- a reference to this, so the API can be used fluently
-
send
public EventBus send(String address, Object message, io.vertx.core.eventbus.DeliveryOptions options) Likesend(String, Object)but specifyingoptionsthat can be used to configure the delivery.- Parameters:
address- the address to send it tomessage- the message, may benulloptions- delivery options- Returns:
- a reference to this, so the API can be used fluently
-
publish
Publish a message.The message will be delivered to all handlers registered to the address.
- Parameters:
address- the address to publish it tomessage- the message, may benull- Returns:
- a reference to this, so the API can be used fluently
-
publish
public EventBus publish(String address, Object message, io.vertx.core.eventbus.DeliveryOptions options) Likepublish(String, Object)but specifyingoptionsthat can be used to configure the delivery.- Parameters:
address- the address to publish it tomessage- the message, may benulloptions- the delivery options- Returns:
- a reference to this, so the API can be used fluently
-
consumer
Create a message consumer against the specified options address.The returned consumer is not yet registered at the address, registration will be effective when
MessageConsumer#handler(io.vertx.core.Handler)is called.- Parameters:
options- the consumer options- Returns:
- the event bus message consumer
-
consumer
public <T> MessageConsumer<T> consumer(io.vertx.core.eventbus.MessageConsumerOptions options, Consumer<Message<T>> handler) Create a consumer and register it against the specified options address.- Parameters:
options- the consumer optionshandler- the handler that will process the received messages- Returns:
- the event bus message consumer
-
consumer
Create a message consumer against the specified address.The returned consumer is not yet registered at the address, registration will be effective when
MessageConsumer#handler(io.vertx.core.Handler)is called.- Parameters:
address- the address that it will register it at- Returns:
- the event bus message consumer
-
consumer
Create a consumer and register it against the specified address.- Parameters:
address- the address that will register it athandler- the handler that will process the received messages- Returns:
- the event bus message consumer
-
localConsumer
Likeconsumer(String)but the address won't be propagated across the cluster.- Parameters:
address- the address to register it at- Returns:
- the event bus message consumer
-
localConsumer
Like#consumer(String, Handler)but the address won't be propagated across the cluster.- Parameters:
address- the address that will register it athandler- the handler that will process the received messages- Returns:
- the event bus message consumer
-
sender
Create a message sender against the specified address.The returned sender will invoke the
send(String, Object)method when the streamWriteStream.write(Object)method is called with the sender address and the provided data.- Parameters:
address- the address to send it to- Returns:
- The sender
-
sender
public <T> MessageProducer<T> sender(String address, io.vertx.core.eventbus.DeliveryOptions options) Likesender(String)but specifying delivery options that will be used for configuring the delivery of the message.- Parameters:
address- the address to send it tooptions- the delivery options- Returns:
- The sender
-
publisher
Create a message publisher against the specified address.The returned publisher will invoke the
publish(String, Object)method when the streamWriteStream.write(Object)method is called with the publisher address and the provided data.- Parameters:
address- The address to publish it to- Returns:
- The publisher
-
publisher
public <T> MessageProducer<T> publisher(String address, io.vertx.core.eventbus.DeliveryOptions options) Likepublisher(String)but specifying delivery options that will be used for configuring the delivery of the message.- Parameters:
address- the address to publish it tooptions- the delivery options- Returns:
- The publisher
-
registerCodec
Register a message codec.You 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.
- Parameters:
codec- the message codec to register- Returns:
- a reference to this, so the API can be used fluently
-
unregisterCodec
Unregister a message codec.- Parameters:
name- the name of the codec- Returns:
- a reference to this, so the API can be used fluently
-
codecSelector
Set selector to be invoked when the bus has not found any codec for aMessagebody.The selector must return the name of a codec which has been registered with either
registerCodec(MessageCodec)or#registerDefaultCodec(Class, MessageCodec).- Parameters:
selector- the codec selector- Returns:
- a reference to this, so the API can be used fluently
-
addOutboundInterceptor
Add an interceptor that will be called whenever a message is sent from Vert.x- Parameters:
interceptor- the interceptor- Returns:
- a reference to this, so the API can be used fluently
-
removeOutboundInterceptor
Remove an interceptor that was added by#addOutboundInterceptor(Handler)- Parameters:
interceptor- the interceptor- Returns:
- a reference to this, so the API can be used fluently
-
addInboundInterceptor
Add an interceptor that will be called whenever a message is received by Vert.x- Parameters:
interceptor- the interceptor- Returns:
- a reference to this, so the API can be used fluently
-
removeInboundInterceptor
Remove an interceptor that was added by#addInboundInterceptor(Handler)- Parameters:
interceptor- the interceptor- Returns:
- a reference to this, so the API can be used fluently
-
clusterSerializableChecker
Register a predicate to invoke when verifying if an object is forbidden to be encoded/decoded asClusterSerializable.This is only used when Vert.x is clustered.
- Parameters:
classNamePredicate- the predicate- Returns:
- a reference to this, so the API can be used fluently
-
serializableChecker
Register a predicate to invoke when verifying if an object is allowed to be encoded/decoded asSerializable.This is only used when Vert.x is clustered.
- Parameters:
classNamePredicate- the predicate- Returns:
- a reference to this, so the API can be used fluently
-
isMetricsEnabled
public boolean isMetricsEnabled()Whether the metrics are enabled for this measured object- Specified by:
isMetricsEnabledin interfaceMeasured- Returns:
trueif metrics are enabled
-
newInstance
Creates a new instance of theEventBus. -
hashCode
public int hashCode() -
equals
-
toString
-