Package kos.core.events
Class EventBusSinkManager
java.lang.Object
kos.core.events.EventBusSinkManager
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Iterable<EventPublisherSink>private final Iterable<EventSubscriptionSink>protected final KosContextprivate final io.vertx.core.impl.logging.Logger -
Constructor Summary
ConstructorsConstructorDescriptionEventBusSinkManager(KosContext kosContext, Iterable<EventSubscriptionSink> eventSubscriberSinks, Iterable<EventPublisherSink> eventPublisherSinks) -
Method Summary
Modifier and TypeMethodDescriptionprivate <T> EventBusSink.EventBusSyncInitializationRequest<T>constructPublishingRequestFor(String address, Class<T> expectedType) <T> io.vertx.core.eventbus.MessageProducer<T>createProducer(String address, Class<T> expectedType) Creates aMessageProducerthat expects messages of typeEventBusSinkManager.<T> voidensureEventBusCanSerializeType(Class<T> targetType) private <T> EventBusSinkManager.InitializationResultperformInitialization(@NonNull String address, Class<T> expectedType, Iterable<? extends EventBusSink> eventBusSinks) <T> voidsubscribe(String address, Class<T> expectedType, io.vertx.core.Handler<io.vertx.core.eventbus.Message<T>> messageHandler) Registers a message consumermessageHandlerthat will receive messages of the typeEventBusSinkManagerpublished into the givenaddress.(package private) final <T> EventBusSinkManager.InitializationResulttryInitializeSink(@NonNull String address, Class<T> expectedType, Iterable<? extends EventBusSink> eventBusSinks) Initializes the Sink responsible for bridging the communication between the localEventBuswith a remote broker, if any.
-
Field Details
-
logger
private final io.vertx.core.impl.logging.Logger logger -
classesWhichCodedHaveBeenRegistered
-
kosContext
-
eventSubscriberSinks
-
eventPublisherSinks
-
-
Constructor Details
-
EventBusSinkManager
public EventBusSinkManager(KosContext kosContext, Iterable<EventSubscriptionSink> eventSubscriberSinks, Iterable<EventPublisherSink> eventPublisherSinks)
-
-
Method Details
-
subscribe
public <T> void subscribe(String address, Class<T> expectedType, io.vertx.core.Handler<io.vertx.core.eventbus.Message<T>> messageHandler) Registers a message consumermessageHandlerthat will receive messages of the typeEventBusSinkManagerpublished into the givenaddress.- Parameters:
address- a free-format String.EventPublisherSinkimplementations might have to parse this address to communicate with external services.expectedType- the expected contract used when serialising messages.- Throws:
KosException- whenever it reaches a terminal, but unrecoverable state.
-
createProducer
public <T> io.vertx.core.eventbus.MessageProducer<T> createProducer(String address, Class<T> expectedType) Creates aMessageProducerthat expects messages of typeEventBusSinkManager.- Parameters:
address- a free-format String.EventPublisherSinkimplementations might have to parse this address to communicate with external services.expectedType- the expected contract used when serialising messages.- Throws:
KosException- whenever it reaches a terminal, but unrecoverable state.
-
tryInitializeSink
final <T> EventBusSinkManager.InitializationResult tryInitializeSink(@NonNull @NonNull String address, Class<T> expectedType, Iterable<? extends EventBusSink> eventBusSinks) Initializes the Sink responsible for bridging the communication between the localEventBuswith a remote broker, if any. Sinks must be able to successfully finish its initialization. Any Exception thrown during this process will be considered a terminal, non-recoverable state - leading to an abrupt interruption of the whole application.- Returns:
-
performInitialization
private <T> EventBusSinkManager.InitializationResult performInitialization(@NonNull @NonNull String address, Class<T> expectedType, Iterable<? extends EventBusSink> eventBusSinks) -
constructPublishingRequestFor
private <T> EventBusSink.EventBusSyncInitializationRequest<T> constructPublishingRequestFor(String address, Class<T> expectedType) -
ensureEventBusCanSerializeType
-