Interface IEventSubscriber
EventKey
. All events
published on this key will be received by subscribers.-
Method Summary
Modifier and TypeMethodDescriptionGet latest event for the given Event Key.Get latest events for multiple Event Keys.akka.stream.javadsl.Source<Event,
IEventSubscription> pSubscribe
(Subsystem subsystem, String pattern) Subscribe to events from Event Keys specified using a subsystem and a pattern to match the remaining Event KeypSubscribeCallback
(Subsystem subsystem, String pattern, Consumer<Event> callback) Subscribes a callback to events from Event Keys specified using a subsystem and a pattern to match the remaining Event Keyakka.stream.javadsl.Source<Event,
IEventSubscription> Subscribe to multiple Event Keys and get a single stream of events for all event keys.akka.stream.javadsl.Source<Event,
IEventSubscription> Subscribe to multiple eventKeys and receive events atevery
frequency according to the specified givenmode
(RateAdapter or RateLimiter).subscribeActorRef
(Set<EventKey> eventKeys, akka.actor.typed.ActorRef<Event> actorRef) Subscribes an actor to events from multiple event keys.subscribeActorRef
(Set<EventKey> eventKeys, akka.actor.typed.ActorRef<Event> actorRef, Duration every, csw.event.api.scaladsl.SubscriptionMode mode) Overload for abovesubscribeActorRef
for receiving event at aevery
frequency according to the specified givemode
.subscribeAsync
(Set<EventKey> eventKeys, scala.Function1<Event, CompletableFuture<?>> callback) Subscribes an asynchronous callback function to events from multiple eventKeys.subscribeAsync
(Set<EventKey> eventKeys, scala.Function1<Event, CompletableFuture<?>> callback, Duration every, csw.event.api.scaladsl.SubscriptionMode mode) Overload for abovesubscribeAsync
for receiving event at aevery
frequency according to the specifiedmode
.subscribeCallback
(Set<EventKey> eventKeys, Consumer<Event> callback) Subscribes a callback function to events from multiple event keys.subscribeCallback
(Set<EventKey> eventKeys, Consumer<Event> callback, Duration every, csw.event.api.scaladsl.SubscriptionMode mode) Overload for abovesubscribeCallback
for receiving event at aevery
frequency according to the specifiedmode
.akka.stream.javadsl.Source<Event,
IEventSubscription> ************ IMPORTANT ************ This API uses redis pattern subscription.
-
Method Details
-
get
Get latest events for multiple Event Keys. The latest events available for the given Event Keys will be received first. If event is not published for one or more event keys,invalid event
will be received for those Event Keys.In case the underlying server is not available, the future fails with
EventServerNotAvailable
exception. In all other cases of exception, the future fails with the respective exception -
get
Get latest event for the given Event Key. If an event is not published for any eventKey, theninvalid event
is returned for that Event Key.In case the underlying server is not available, the future fails with
EventServerNotAvailable
exception. In all other cases of exception, the future fails with the respective exception -
pSubscribe
akka.stream.javadsl.Source<Event,IEventSubscription> pSubscribe(Subsystem subsystem, String pattern) Subscribe to events from Event Keys specified using a subsystem and a pattern to match the remaining Event KeyAt the time of invocation, in case the underlying server is not available,
EventServerNotAvailable
exception is thrown and the subscription is stopped after logging appropriately. {@link csw.event.api.scaladsl.EventSubscription!.ready} method can be used to determine this state. In all other cases of exception, the subscription resumes to receive remaining elements.- Parameters:
subsystem
- a validSubsystem
which represents the source of the eventspattern
- Subscribes the client to the given patterns. Supported glob-style patterns: - h?llo subscribes to hello, hallo and hxllo - h*llo subscribes to hllo and heeeello - h[ae]llo subscribes to hello and hallo, but not hillo Use \ to escape special characters if you want to match them verbatim.- Returns:
- a
Source
ofEvent
. The materialized value of the source provides anIEventSubscription
which can be used to unsubscribe from all the Event Keys which were subscribed to
-
pSubscribeCallback
IEventSubscription pSubscribeCallback(Subsystem subsystem, String pattern, Consumer<Event> callback) Subscribes a callback to events from Event Keys specified using a subsystem and a pattern to match the remaining Event KeyAt the time of invocation, in case the underlying server is not available,
EventServerNotAvailable
exception is thrown and the subscription is stopped after logging appropriately. {@link csw.event.api.scaladsl.EventSubscription!.ready} method can be used to determine this state. In all other cases of exception, the subscription resumes to receive remaining elements.Note that callbacks are not thread-safe on the JVM. If you are doing side effects/mutations inside the callback, you should ensure that it is done in a thread-safe way inside an actor.
- Parameters:
subsystem
- a validSubsystem
which represents the source of the eventspattern
- Subscribes the client to the given patterns. Supported glob-style patterns: - h?llo subscribes to hello, hallo and hxllo - h*llo subscribes to hllo and heeeello - h[ae]llo subscribes to hello and hallo, but not hillo Use \ to escape special characters if you want to match them verbatim.callback
- a consumer which defines an operation to execute on each received event- Returns:
- an
IEventSubscription
which can be used to unsubscribe from all the Event Keys which were subscribed to
-
subscribe
Subscribe to multiple Event Keys and get a single stream of events for all event keys. The latest events available for the given Event Keys will be received first. If event is not published for one or more event keys,invalid event
will be received for those Event Keys.At the time of invocation, in case the underlying server is not available
EventServerNotAvailable
exception is thrown and the stream is stopped after logging appropriately. In all other cases of exception, the stream resumes to receive remaining elements.- Parameters:
eventKeys
- a set ofEventKey
to subscribe to- Returns:
- a
Source
ofEvent
. The materialized value of the source provides anIEventSubscription
which can be used to unsubscribe from all the Event Keys which were subscribed to
-
subscribe
akka.stream.javadsl.Source<Event,IEventSubscription> subscribe(Set<EventKey> eventKeys, Duration every, csw.event.api.scaladsl.SubscriptionMode mode) Subscribe to multiple eventKeys and receive events atevery
frequency according to the specified givenmode
(RateAdapter or RateLimiter). The latest events available for the given Event Keys will be received first. If event is not published for one or more event keys,invalid event
will be received for those Event Keys.At the time of invocation, in case the underlying server is not available,
EventServerNotAvailable
exception is thrown and the stream is stopped after logging appropriately. In all other cases of exception, the stream resumes to receive remaining elements.- Parameters:
eventKeys
- a set ofEventKey
to subscribe toevery
- the duration which determines the frequency with which events are receivedmode
- an appropriateSubscriptionMode
to control the behavior of rate of events w.r.t. the given frequency. Refer the API documentation for SubscriptionMode for more details- Returns:
- a
Source
ofEvent
. The materialized value of the source provides anIEventSubscription
which can be used to unsubscribe from all the Event Keys which were subscribed to
-
subscribeActorRef
IEventSubscription subscribeActorRef(Set<EventKey> eventKeys, akka.actor.typed.ActorRef<Event> actorRef) Subscribes an actor to events from multiple event keys. The latest events available for the given Event Keys will be received first. If event is not published for one or more event keys,invalid event
will be received for those Event Keys.At the time of invocation, in case the underlying server is not available,
EventServerNotAvailable
exception is thrown and the subscription is stopped after logging appropriately. {@link csw.event.api.scaladsl.EventSubscription!.ready} method can be used to determine this state. In all other cases of exception, the subscription resumes to receive remaining elements.- Parameters:
eventKeys
- a set ofEventKey
to subscribe toactorRef
- an actorRef of an actor which handles each received event- Returns:
- an
IEventSubscription
which can be used to unsubscribe from all the Event Keys which were subscribed to
-
subscribeActorRef
IEventSubscription subscribeActorRef(Set<EventKey> eventKeys, akka.actor.typed.ActorRef<Event> actorRef, Duration every, csw.event.api.scaladsl.SubscriptionMode mode) Overload for abovesubscribeActorRef
for receiving event at aevery
frequency according to the specified givemode
. The latest events available for the given Event Keys will be received first. If event is not published for one or more event keys,invalid event
will be received for those Event Keys.At the time of invocation, in case the underlying server is not available,
EventServerNotAvailable
exception is thrown and the subscription is stopped after logging appropriately. {@link csw.event.api.scaladsl.EventSubscription!.ready} method can be used to determine this state. In all other cases of exception, the subscription resumes to receive remaining elements.- Parameters:
eventKeys
- a set ofEventKey
to subscribe toactorRef
- an actorRef of an actor to which each received event is redirectedevery
- the duration which determines the frequency with which events are receivedmode
- an appropriateSubscriptionMode
to control the behavior of rate of events w.r.t. the given frequency. Refer the API documentation for SubscriptionMode for more details- Returns:
- an
IEventSubscription
which can be used to unsubscribe from all the Event Keys which were subscribed to
-
subscribeAsync
IEventSubscription subscribeAsync(Set<EventKey> eventKeys, scala.Function1<Event, CompletableFuture<?>> callback) Subscribes an asynchronous callback function to events from multiple eventKeys. The callback is of type event => future and it ensures that the event callbacks are called sequentially in such a way that the subsequent execution will start only after the prior one completes. This API gives the guarantee of ordered execution of the asynchronous callbacks.The latest events available for the given Event Keys will be received first. If event is not published for one or more event keys,
invalid event
will be received for those Event Keys.At the time of invocation, in case the underlying server is not available,
EventServerNotAvailable
exception is thrown and the subscription is stopped after logging appropriately. {@link csw.event.api.scaladsl.EventSubscription!.ready} method can be used to determine this state. In all other cases of exception, the subscription resumes to receive remaining elements.Note that callbacks are not thread-safe on the JVM. If you need to do side effects/mutations, prefer using
subscribeActorRef
API.- Parameters:
eventKeys
- a set ofEventKey
to subscribe tocallback
- a function to execute asynchronously on each received event- Returns:
- an
IEventSubscription
which can be used to unsubscribe from all the Event Keys which were subscribed to
-
subscribeAsync
IEventSubscription subscribeAsync(Set<EventKey> eventKeys, scala.Function1<Event, CompletableFuture<?>> callback, Duration every, csw.event.api.scaladsl.SubscriptionMode mode) Overload for abovesubscribeAsync
for receiving event at aevery
frequency according to the specifiedmode
. The latest events available for the given Event Keys will be received first. If event is not published for one or more event keys,invalid event
will be received for those Event Keys.At the time of invocation, in case the underlying server is not available,
EventServerNotAvailable
exception is thrown and the subscription is stopped after logging appropriately. {@link csw.event.api.scaladsl.EventSubscription!.ready} method can be used to determine this state. In all other cases of exception, the subscription resumes to receive remaining elements.- Parameters:
eventKeys
- a set ofEventKey
to subscribe tocallback
- a function to execute on each received eventevery
- the duration which determines the frequency with which events are receivedmode
- an appropriateSubscriptionMode
to control the behavior of rate of events w.r.t. the given frequency. Refer the API documentation for SubscriptionMode for more details- Returns:
- an
IEventSubscription
which can be used to unsubscribe from all the Event Keys which were subscribed to
-
subscribeCallback
Subscribes a callback function to events from multiple event keys. The latest events available for the given Event Keys will be received first. If event is not published for one or more event keys,invalid event
will be received for those Event Keys.At the time of invocation, in case the underlying server is not available,
EventServerNotAvailable
exception is thrown and the subscription is stopped after logging appropriately. {@link csw.event.api.scaladsl.EventSubscription!.ready} method can be used to determine this state. In all other cases of exception, the subscription resumes to receive remaining elements.Note that callbacks are not thread-safe on the JVM. If you need to do side effects/mutations, prefer using
subscribeActorRef
API. Also note that any exception thrown fromcallback
is expected to be handled by component developers.- Parameters:
eventKeys
- a set ofEventKey
to subscribe tocallback
- a consumer which defines an operation to execute on each received event- Returns:
- an
IEventSubscription
which can be used to unsubscribe from all the Event Keys which were subscribed to
-
subscribeCallback
IEventSubscription subscribeCallback(Set<EventKey> eventKeys, Consumer<Event> callback, Duration every, csw.event.api.scaladsl.SubscriptionMode mode) Overload for abovesubscribeCallback
for receiving event at aevery
frequency according to the specifiedmode
. The latest events available for the given Event Keys will be received first. If event is not published for one or more event keys,invalid event
will be received for those Event Keys.At the time of invocation, in case the underlying server is not available,
EventServerNotAvailable
exception is thrown and the subscription is stopped after logging appropriately. {@link csw.event.api.scaladsl.EventSubscription!.ready} method can be used to determine this state. In all other cases of exception, the subscription resumes to receive remaining elements.- Parameters:
eventKeys
- a set ofEventKey
to subscribe tocallback
- a consumer which defines an operation to execute on each received eventevery
- the duration which determines the frequency with which events are receivedmode
- an appropriateSubscriptionMode
to control the behavior of rate of events w.r.t. the given frequency. Refer the API documentation for SubscriptionMode for more details- Returns:
- an
IEventSubscription
which can be used to unsubscribe from all the Event Keys which were subscribed to
-
subscribeObserveEvents
akka.stream.javadsl.Source<Event,IEventSubscription> subscribeObserveEvents()************ IMPORTANT ************ This API uses redis pattern subscription. Having many live pattern subscriptions causes overall latency degradation. Prefer subscribe API over this whenever possible. *********** ********* ************Subscribe to all the observe events
At the time of invocation, in case the underlying server is not available,
EventServerNotAvailable
exception is thrown and the subscription is stopped after logging appropriately. {@link csw.event.api.scaladsl.EventSubscription!.ready} method can be used to determine this state. In all other cases of exception, the subscription resumes to receive remaining elements.- Returns:
- a
Source
ofEvent
. The materialized value of the source provides anEventSubscription
which can be used to unsubscribe from observe events subscription
-