Interface IEventPublisher


public interface IEventPublisher
An EventPublisher interface to publish events. The published events are published on a key determined by EventKey in the Event model. This key can be used by the subscribers using IEventSubscriber interface to subscribe to the events.
  • Method Details

    • publish

      CompletableFuture<akka.Done> publish(Event event)
      Publish a single Event

      At the time of invocation, in case the underlying server is not available, EventServerNotAvailable exception is thrown, in all other cases PublishFailure exception is thrown which wraps the underlying exception and also provides the handle to the event which was failed to be published

      Parameters:
      event - an event to be published
      Returns:
      a completable future which completes when the event is published
    • publish

      <Mat> Mat publish(akka.stream.javadsl.Source<Event,Mat> source)
      Publish from a stream of Event

      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 receives a PublishFailure exception which wraps the underlying exception. The stream resumes to publish remaining elements in case of this exception.

      Parameters:
      source - a Source of events to be published
      Returns:
      the materialized value obtained on running the stream
    • publish

      <Mat> Mat publish(akka.stream.javadsl.Source<Event,Mat> source, Consumer<PublishFailure> onError)
      Publish from a stream of Event, and perform an operation defined using onError consumer for each event for which publishing failed

      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 receives a PublishFailure exception which wraps the underlying exception and also provides the handle to the event which was failed to be published. The provided callback is executed on the failed element and the stream resumes to publish remaining elements.

      Parameters:
      source - a Source of events to be published
      onError - a consumer which defines an operation for each event for which publishing failed
      Returns:
      the materialized value obtained on running the stream
    • publish

      akka.actor.Cancellable publish(Supplier<Optional<Event>> eventGenerator, Duration every)
      Publish Event from an eventGenerator supplier, which will be executed at every frequency. Cancellable can be used to cancel the execution of eventGenerator function.

      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 receives a PublishFailure exception which wraps the underlying exception. The generator resumes to publish remaining elements in case of this exception.

      Parameters:
      eventGenerator - a supplier which can generate an event to be published at every frequency
      every - frequency with which the events are to be published
      Returns:
      a handle to cancel the event generation through eventGenerator
    • publish

      akka.actor.Cancellable publish(Supplier<Optional<Event>> eventGenerator, TMTTime startTime, Duration every)
      Publish Event from an eventGenerator supplier, which will be started at the specified startTime and will be executed at every frequency. Cancellable can be used to cancel the execution of eventGenerator function.

      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 receives a PublishFailure exception which wraps the underlying exception. The generator resumes to publish remaining elements in case of this exception.

      Parameters:
      eventGenerator - a supplier which can generate an event to be published at every frequency
      startTime - the time at which the eventGenerator should start generating events
      every - frequency with which the events are to be published
      Returns:
      a handle to cancel the event generation through eventGenerator
    • publish

      akka.actor.Cancellable publish(Supplier<Optional<Event>> eventGenerator, Duration every, Consumer<PublishFailure> onError)
      Publish Event from an eventGenerator supplier, which will be executed at every frequency. Also, provide onError consumer to perform an operation for each event for which publishing failed.

      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 receives a PublishFailure exception which wraps the underlying exception and also provides the handle to the event which was failed to be published. The provided callback is executed on the failed element and the generator resumes to publish remaining elements.

      Note that any exception thrown from onError consumer is expected to be handled by component developers.

      Parameters:
      eventGenerator - a function which can generate an event to be published at every frequency
      every - frequency with which the events are to be published
      onError - a consumer which defines an operation for each event for which publishing failed
      Returns:
      a handle to cancel the event generation through eventGenerator
    • publish

      akka.actor.Cancellable publish(Supplier<Optional<Event>> eventGenerator, TMTTime startTime, Duration every, Consumer<PublishFailure> onError)
      Publish Event from an eventGenerator supplier, which will be started at the specified startTime and will be executed at every frequency. Also, provide onError consumer to perform an operation for each event for which publishing failed.

      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 receives a PublishFailure exception which wraps the underlying exception and also provides the handle to the event which was failed to be published. The provided callback is executed on the failed element and the generator resumes to publish remaining elements.

      Note that any exception thrown from onError consumer is expected to be handled by component developers.

      Parameters:
      eventGenerator - a supplier which can generate an event to be published at every frequency
      startTime - the time at which the eventGenerator should start generating events
      every - frequency with which the events are to be published
      onError - a consumer which defines an operation for each event for which publishing failed
      Returns:
      a handle to cancel the event generation through eventGenerator
    • publishAsync

      akka.actor.Cancellable publishAsync(Supplier<CompletableFuture<Optional<Event>>> eventGenerator, Duration every)
      Publish Event from an eventGenerator supplier, which will be executed at every frequency. Cancellable can be used to cancel the execution of eventGenerator function. Prefer this version if eventGenerator closes over mutable state. This method allows caller to prepare future on it's own execution context to make it thread safe.

      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 receives a PublishFailure exception which wraps the underlying exception. The generator resumes to publish remaining elements in case of this exception.

      Parameters:
      eventGenerator - a supplier which can generate Future of event to be published at every frequency
      every - frequency with which the events are to be published
      Returns:
      a handle to cancel the event generation through eventGenerator
    • publishAsync

      akka.actor.Cancellable publishAsync(Supplier<CompletableFuture<Optional<Event>>> eventGenerator, TMTTime startTime, Duration every)
      Publish Event from an eventGenerator supplier, which will be started at the specified startTime and will be executed at every frequency. Also, provide onError callback for each event for which publishing failed. Prefer this version if eventGenerator closes over mutable state. This method allows caller to prepare future on it's own execution context to make it thread safe.

      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 receives a PublishFailure exception which wraps the underlying exception and also provides the handle to the event which was failed to be published.

      Parameters:
      eventGenerator - a supplier which can generate a Future of event to be published at every frequency
      startTime - the time at which the eventGenerator should start generating events
      every - frequency with which the events are to be published
      Returns:
      a handle to cancel the event generation through eventGenerator
    • publishAsync

      akka.actor.Cancellable publishAsync(Supplier<CompletableFuture<Optional<Event>>> eventGenerator, Duration every, Consumer<PublishFailure> onError)
      Publish Event from an eventGenerator supplier, which will be executed at every frequency. Also, provide onError consumer to perform an operation for each event for which publishing failed. Prefer this version if eventGenerator closes over mutable state. This method allows caller to prepare future on it's own execution context to make it thread safe.

      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 receives a PublishFailure exception which wraps the underlying exception and also provides the handle to the event which was failed to be published. The provided callback is executed on the failed element and the generator resumes to publish remaining elements.

      Note that any exception thrown from onError callback is expected to be handled by component developers.

      Parameters:
      eventGenerator - a function which can generate Future of event to be published at every frequency
      every - frequency with which the events are to be published
      onError - a consumer which defines an operation for each event for which publishing failed
      Returns:
      a handle to cancel the event generation through eventGenerator
    • publishAsync

      akka.actor.Cancellable publishAsync(Supplier<CompletableFuture<Optional<Event>>> eventGenerator, TMTTime startTime, Duration every, Consumer<PublishFailure> onError)
      Publish Event from an eventGenerator supplier, which will be started at the specified startTime and will be executed at every frequency. Also, provide onError callback for each event for which publishing failed. Prefer this version if eventGenerator closes over mutable state. This method allows caller to prepare future on it's own execution context to make it thread safe.

      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 receives a PublishFailure exception which wraps the underlying exception and also provides the handle to the event which was failed to be published. The provided callback is executed on the failed element and the generator resumes to publish remaining elements.

      Note that any exception thrown from onError consumer is expected to be handled by component developers.

      Parameters:
      eventGenerator - a supplier which can generate a Future of event to be published at every frequency
      startTime - the time at which the eventGenerator should start generating events
      every - frequency with which the events are to be published
      onError - a consumer to execute for each event for which publishing failed
      Returns:
      a handle to cancel the event generation through eventGenerator
    • shutdown

      CompletableFuture<akka.Done> shutdown()
      Shuts down the connection for this publisher. Using any api of publisher after shutdown should give exceptions. This method should be called while the component is shutdown gracefully.

      Any exception that occurs will cause the future to complete with a Failure.

      Returns:
      a future which completes when the underlying connection is shut down