Interface IEventSubscriber


  • public interface IEventSubscriber
    An EventSubscriber interface to subscribe events. The events can be subscribed on EventKey. All events published on this key will be received by subscribers.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.util.concurrent.CompletableFuture<Event> get​(EventKey eventKey)
      Get latest event for the given Event Key.
      java.util.concurrent.CompletableFuture<java.util.Set<Event>> get​(java.util.Set<EventKey> eventKeys)
      Get latest events for multiple Event Keys.
      akka.stream.javadsl.Source<Event,​IEventSubscription> pSubscribe​(Subsystem subsystem, java.lang.String pattern)
      Subscribe to events from Event Keys specified using a subsystem and a pattern to match the remaining Event Key
      IEventSubscription pSubscribeCallback​(Subsystem subsystem, java.lang.String pattern, java.util.function.Consumer<Event> callback)
      Subscribes a callback to events from Event Keys specified using a subsystem and a pattern to match the remaining Event Key
      akka.stream.javadsl.Source<Event,​IEventSubscription> subscribe​(java.util.Set<EventKey> eventKeys)
      Subscribe to multiple Event Keys and get a single stream of events for all event keys.
      akka.stream.javadsl.Source<Event,​IEventSubscription> subscribe​(java.util.Set<EventKey> eventKeys, java.time.Duration every, csw.event.api.scaladsl.SubscriptionMode mode)
      Subscribe to multiple eventKeys and receive events at every frequency according to the specified given mode (RateAdapter or RateLimiter).
      IEventSubscription subscribeActorRef​(java.util.Set<EventKey> eventKeys, akka.actor.typed.ActorRef<Event> actorRef)
      Subscribes an actor to events from multiple event keys.
      IEventSubscription subscribeActorRef​(java.util.Set<EventKey> eventKeys, akka.actor.typed.ActorRef<Event> actorRef, java.time.Duration every, csw.event.api.scaladsl.SubscriptionMode mode)
      Overload for above subscribeActorRef for receiving event at a every frequency according to the specified give mode.
      IEventSubscription subscribeAsync​(java.util.Set<EventKey> eventKeys, scala.Function1<Event,​java.util.concurrent.CompletableFuture<?>> callback)
      Subscribes an asynchronous callback function to events from multiple eventKeys.
      IEventSubscription subscribeAsync​(java.util.Set<EventKey> eventKeys, scala.Function1<Event,​java.util.concurrent.CompletableFuture<?>> callback, java.time.Duration every, csw.event.api.scaladsl.SubscriptionMode mode)
      Overload for above subscribeAsync for receiving event at a every frequency according to the specified mode.
      IEventSubscription subscribeCallback​(java.util.Set<EventKey> eventKeys, java.util.function.Consumer<Event> callback)
      Subscribes a callback function to events from multiple event keys.
      IEventSubscription subscribeCallback​(java.util.Set<EventKey> eventKeys, java.util.function.Consumer<Event> callback, java.time.Duration every, csw.event.api.scaladsl.SubscriptionMode mode)
      Overload for above subscribeCallback for receiving event at a every frequency according to the specified mode.
    • Method Detail

      • get

        java.util.concurrent.CompletableFuture<java.util.Set<Event>> get​(java.util.Set<EventKey> eventKeys)
        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

        Parameters:
        eventKeys - a set of EventKey to subscribe to
        Returns:
        a completable future which completes with a set of latest Event for the provided Event Keys
      • get

        java.util.concurrent.CompletableFuture<Event> get​(EventKey eventKey)
        Get latest event for the given Event Key. If an event is not published for any eventKey, then invalid 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

        Parameters:
        eventKey - an EventKey to subscribe to
        Returns:
        a completable future which completes with the latest Event for the provided Event Key
      • pSubscribe

        akka.stream.javadsl.Source<Event,​IEventSubscription> pSubscribe​(Subsystem subsystem,
                                                                              java.lang.String pattern)
        Subscribe to events from Event Keys specified using a subsystem and a pattern to match the remaining Event Key

        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:
        subsystem - a valid Subsystem which represents the source of the events
        pattern - 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 of Event. The materialized value of the source provides an IEventSubscription which can be used to unsubscribe from all the Event Keys which were subscribed to
      • pSubscribeCallback

        IEventSubscription pSubscribeCallback​(Subsystem subsystem,
                                              java.lang.String pattern,
                                              java.util.function.Consumer<Event> callback)
        Subscribes a callback to events from Event Keys specified using a subsystem and a pattern to match the remaining Event Key

        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 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 valid Subsystem which represents the source of the events
        pattern - 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

        akka.stream.javadsl.Source<Event,​IEventSubscription> subscribe​(java.util.Set<EventKey> eventKeys)
        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 of EventKey to subscribe to
        Returns:
        a Source of Event. The materialized value of the source provides an IEventSubscription which can be used to unsubscribe from all the Event Keys which were subscribed to
      • subscribe

        akka.stream.javadsl.Source<Event,​IEventSubscription> subscribe​(java.util.Set<EventKey> eventKeys,
                                                                             java.time.Duration every,
                                                                             csw.event.api.scaladsl.SubscriptionMode mode)
        Subscribe to multiple eventKeys and receive events at every frequency according to the specified given mode (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 of EventKey to subscribe to
        every - the duration which determines the frequency with which events are received
        mode - an appropriate SubscriptionMode 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 of Event. The materialized value of the source provides an IEventSubscription which can be used to unsubscribe from all the Event Keys which were subscribed to
      • subscribeActorRef

        IEventSubscription subscribeActorRef​(java.util.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 of EventKey to subscribe to
        actorRef - 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​(java.util.Set<EventKey> eventKeys,
                                             akka.actor.typed.ActorRef<Event> actorRef,
                                             java.time.Duration every,
                                             csw.event.api.scaladsl.SubscriptionMode mode)
        Overload for above subscribeActorRef for receiving event at a every frequency according to the specified give mode. 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 of EventKey to subscribe to
        actorRef - an actorRef of an actor to which each received event is redirected
        every - the duration which determines the frequency with which events are received
        mode - an appropriate SubscriptionMode 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​(java.util.Set<EventKey> eventKeys,
                                          scala.Function1<Event,​java.util.concurrent.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 of EventKey to subscribe to
        callback - 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​(java.util.Set<EventKey> eventKeys,
                                          scala.Function1<Event,​java.util.concurrent.CompletableFuture<?>> callback,
                                          java.time.Duration every,
                                          csw.event.api.scaladsl.SubscriptionMode mode)
        Overload for above subscribeAsync for receiving event at a every frequency according to the specified mode. 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 of EventKey to subscribe to
        callback - a function to execute on each received event
        every - the duration which determines the frequency with which events are received
        mode - an appropriate SubscriptionMode 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

        IEventSubscription subscribeCallback​(java.util.Set<EventKey> eventKeys,
                                             java.util.function.Consumer<Event> callback)
        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 from callback is expected to be handled by component developers.

        Parameters:
        eventKeys - a set of EventKey to subscribe to
        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
      • subscribeCallback

        IEventSubscription subscribeCallback​(java.util.Set<EventKey> eventKeys,
                                             java.util.function.Consumer<Event> callback,
                                             java.time.Duration every,
                                             csw.event.api.scaladsl.SubscriptionMode mode)
        Overload for above subscribeCallback for receiving event at a every frequency according to the specified mode. 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 of EventKey to subscribe to
        callback - a consumer which defines an operation to execute on each received event
        every - the duration which determines the frequency with which events are received
        mode - an appropriate SubscriptionMode 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