Interface IEventPublisher
-
public interface IEventPublisherAn EventPublisher interface to publish events. The published events are published on a key determined byEventKeyin theEventmodel. This key can be used by the subscribers usingIEventSubscriberinterface to subscribe to the events.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <Mat> Matpublish(akka.stream.javadsl.Source<Event,Mat> source)Publish from a stream ofEvent<Mat> Matpublish(akka.stream.javadsl.Source<Event,Mat> source, java.util.function.Consumer<PublishFailure> onError)Publish from a stream ofEvent, and perform an operation defined usingonErrorconsumer for each event for which publishing failedjava.util.concurrent.CompletableFuture<akka.Done>publish(Event event)Publish a singleEventakka.actor.Cancellablepublish(java.util.function.Supplier<java.util.Optional<Event>> eventGenerator, TMTTime startTime, java.time.Duration every)PublishEventfrom aneventGeneratorsupplier, which will be started at the specifiedstartTimeand will be executed ateveryfrequency.akka.actor.Cancellablepublish(java.util.function.Supplier<java.util.Optional<Event>> eventGenerator, TMTTime startTime, java.time.Duration every, java.util.function.Consumer<PublishFailure> onError)PublishEventfrom aneventGeneratorsupplier, which will be started at the specifiedstartTimeand will be executed ateveryfrequency.akka.actor.Cancellablepublish(java.util.function.Supplier<java.util.Optional<Event>> eventGenerator, java.time.Duration every)akka.actor.Cancellablepublish(java.util.function.Supplier<java.util.Optional<Event>> eventGenerator, java.time.Duration every, java.util.function.Consumer<PublishFailure> onError)akka.actor.CancellablepublishAsync(java.util.function.Supplier<java.util.concurrent.CompletableFuture<java.util.Optional<Event>>> eventGenerator, TMTTime startTime, java.time.Duration every)PublishEventfrom aneventGeneratorsupplier, which will be started at the specifiedstartTimeand will be executed ateveryfrequency.akka.actor.CancellablepublishAsync(java.util.function.Supplier<java.util.concurrent.CompletableFuture<java.util.Optional<Event>>> eventGenerator, TMTTime startTime, java.time.Duration every, java.util.function.Consumer<PublishFailure> onError)PublishEventfrom aneventGeneratorsupplier, which will be started at the specifiedstartTimeand will be executed ateveryfrequency.akka.actor.CancellablepublishAsync(java.util.function.Supplier<java.util.concurrent.CompletableFuture<java.util.Optional<Event>>> eventGenerator, java.time.Duration every)akka.actor.CancellablepublishAsync(java.util.function.Supplier<java.util.concurrent.CompletableFuture<java.util.Optional<Event>>> eventGenerator, java.time.Duration every, java.util.function.Consumer<PublishFailure> onError)java.util.concurrent.CompletableFuture<akka.Done>shutdown()Shuts down the connection for this publisher.
-
-
-
Method Detail
-
publish
java.util.concurrent.CompletableFuture<akka.Done> publish(Event event)
Publish a singleEventAt the time of invocation, in case the underlying server is not available,
EventServerNotAvailableexception is thrown, in all other casesPublishFailureexception 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 ofEventAt the time of invocation, in case the underlying server is not available,
EventServerNotAvailableexception is thrown and the stream is stopped after logging appropriately. In all other cases of exception, the stream receives aPublishFailureexception which wraps the underlying exception. The stream resumes to publish remaining elements in case of this exception.- Parameters:
source- aSourceof events to be published- Returns:
- the materialized value obtained on running the stream
-
publish
<Mat> Mat publish(akka.stream.javadsl.Source<Event,Mat> source, java.util.function.Consumer<PublishFailure> onError)
Publish from a stream ofEvent, and perform an operation defined usingonErrorconsumer for each event for which publishing failedAt the time of invocation, in case the underlying server is not available,
EventServerNotAvailableexception is thrown and the stream is stopped after logging appropriately. In all other cases of exception, the stream receives aPublishFailureexception 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- aSourceof events to be publishedonError- 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(java.util.function.Supplier<java.util.Optional<Event>> eventGenerator, java.time.Duration every)
PublishEventfrom aneventGeneratorsupplier, which will be executed ateveryfrequency.Cancellablecan be used to cancel the execution ofeventGeneratorfunction.At the time of invocation, in case the underlying server is not available,
EventServerNotAvailableexception is thrown and the stream is stopped after logging appropriately. In all other cases of exception, the stream receives aPublishFailureexception 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 ateveryfrequencyevery- frequency with which the events are to be published- Returns:
- a handle to cancel the event generation through
eventGenerator
-
publish
akka.actor.Cancellable publish(java.util.function.Supplier<java.util.Optional<Event>> eventGenerator, TMTTime startTime, java.time.Duration every)
PublishEventfrom aneventGeneratorsupplier, which will be started at the specifiedstartTimeand will be executed ateveryfrequency.Cancellablecan be used to cancel the execution ofeventGeneratorfunction.At the time of invocation, in case the underlying server is not available,
EventServerNotAvailableexception is thrown and the stream is stopped after logging appropriately. In all other cases of exception, the stream receives aPublishFailureexception 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 ateveryfrequencystartTime- the time at which theeventGeneratorshould start generating eventsevery- frequency with which the events are to be published- Returns:
- a handle to cancel the event generation through
eventGenerator
-
publish
akka.actor.Cancellable publish(java.util.function.Supplier<java.util.Optional<Event>> eventGenerator, java.time.Duration every, java.util.function.Consumer<PublishFailure> onError)
PublishEventfrom aneventGeneratorsupplier, which will be executed ateveryfrequency. Also, provideonErrorconsumer to perform an operation for each event for which publishing failed.At the time of invocation, in case the underlying server is not available,
EventServerNotAvailableexception is thrown and the stream is stopped after logging appropriately. In all other cases of exception, the stream receives aPublishFailureexception 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
onErrorconsumer is expected to be handled by component developers.- Parameters:
eventGenerator- a function which can generate an event to be published ateveryfrequencyevery- frequency with which the events are to be publishedonError- 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(java.util.function.Supplier<java.util.Optional<Event>> eventGenerator, TMTTime startTime, java.time.Duration every, java.util.function.Consumer<PublishFailure> onError)
PublishEventfrom aneventGeneratorsupplier, which will be started at the specifiedstartTimeand will be executed ateveryfrequency. Also, provideonErrorconsumer to perform an operation for each event for which publishing failed.At the time of invocation, in case the underlying server is not available,
EventServerNotAvailableexception is thrown and the stream is stopped after logging appropriately. In all other cases of exception, the stream receives aPublishFailureexception 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
onErrorconsumer is expected to be handled by component developers.- Parameters:
eventGenerator- a supplier which can generate an event to be published ateveryfrequencystartTime- the time at which theeventGeneratorshould start generating eventsevery- frequency with which the events are to be publishedonError- 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(java.util.function.Supplier<java.util.concurrent.CompletableFuture<java.util.Optional<Event>>> eventGenerator, java.time.Duration every)
PublishEventfrom aneventGeneratorsupplier, which will be executed ateveryfrequency.Cancellablecan be used to cancel the execution ofeventGeneratorfunction. 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,
EventServerNotAvailableexception is thrown and the stream is stopped after logging appropriately. In all other cases of exception, the stream receives aPublishFailureexception 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 ateveryfrequencyevery- frequency with which the events are to be published- Returns:
- a handle to cancel the event generation through
eventGenerator
-
publishAsync
akka.actor.Cancellable publishAsync(java.util.function.Supplier<java.util.concurrent.CompletableFuture<java.util.Optional<Event>>> eventGenerator, TMTTime startTime, java.time.Duration every)
PublishEventfrom aneventGeneratorsupplier, which will be started at the specifiedstartTimeand will be executed ateveryfrequency. Also, provideonErrorcallback 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,
EventServerNotAvailableexception is thrown and the stream is stopped after logging appropriately. In all other cases of exception, the stream receives aPublishFailureexception 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 ateveryfrequencystartTime- the time at which theeventGeneratorshould start generating eventsevery- frequency with which the events are to be published- Returns:
- a handle to cancel the event generation through
eventGenerator
-
publishAsync
akka.actor.Cancellable publishAsync(java.util.function.Supplier<java.util.concurrent.CompletableFuture<java.util.Optional<Event>>> eventGenerator, java.time.Duration every, java.util.function.Consumer<PublishFailure> onError)
PublishEventfrom aneventGeneratorsupplier, which will be executed ateveryfrequency. Also, provideonErrorconsumer 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,
EventServerNotAvailableexception is thrown and the stream is stopped after logging appropriately. In all other cases of exception, the stream receives aPublishFailureexception 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
onErrorcallback is expected to be handled by component developers.- Parameters:
eventGenerator- a function which can generate Future of event to be published ateveryfrequencyevery- frequency with which the events are to be publishedonError- 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(java.util.function.Supplier<java.util.concurrent.CompletableFuture<java.util.Optional<Event>>> eventGenerator, TMTTime startTime, java.time.Duration every, java.util.function.Consumer<PublishFailure> onError)
PublishEventfrom aneventGeneratorsupplier, which will be started at the specifiedstartTimeand will be executed ateveryfrequency. Also, provideonErrorcallback 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,
EventServerNotAvailableexception is thrown and the stream is stopped after logging appropriately. In all other cases of exception, the stream receives aPublishFailureexception 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
onErrorconsumer is expected to be handled by component developers.- Parameters:
eventGenerator- a supplier which can generate a Future of event to be published ateveryfrequencystartTime- the time at which theeventGeneratorshould start generating eventsevery- frequency with which the events are to be publishedonError- a consumer to execute for each event for which publishing failed- Returns:
- a handle to cancel the event generation through
eventGenerator
-
shutdown
java.util.concurrent.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
-
-