Interface IEventPublisher
EventKey
in the Event
model. This key can be used by the subscribers using IEventSubscriber
interface to subscribe to the events.-
Method Summary
Modifier and TypeMethodDescription<Mat> Mat
Publish from a stream ofEvent
<Mat> Mat
publish
(akka.stream.javadsl.Source<Event, Mat> source, Consumer<PublishFailure> onError) Publish from a stream ofEvent
, and perform an operation defined usingonError
consumer for each event for which publishing failedCompletableFuture<akka.Done>
Publish a singleEvent
akka.actor.Cancellable
PublishEvent
from aneventGenerator
supplier, which will be started at the specifiedstartTime
and will be executed atevery
frequency.akka.actor.Cancellable
publish
(Supplier<Optional<Event>> eventGenerator, TMTTime startTime, Duration every, Consumer<PublishFailure> onError) PublishEvent
from aneventGenerator
supplier, which will be started at the specifiedstartTime
and will be executed atevery
frequency.akka.actor.Cancellable
akka.actor.Cancellable
akka.actor.Cancellable
publishAsync
(Supplier<CompletableFuture<Optional<Event>>> eventGenerator, TMTTime startTime, Duration every) PublishEvent
from aneventGenerator
supplier, which will be started at the specifiedstartTime
and will be executed atevery
frequency.akka.actor.Cancellable
publishAsync
(Supplier<CompletableFuture<Optional<Event>>> eventGenerator, TMTTime startTime, Duration every, Consumer<PublishFailure> onError) PublishEvent
from aneventGenerator
supplier, which will be started at the specifiedstartTime
and will be executed atevery
frequency.akka.actor.Cancellable
publishAsync
(Supplier<CompletableFuture<Optional<Event>>> eventGenerator, Duration every) akka.actor.Cancellable
publishAsync
(Supplier<CompletableFuture<Optional<Event>>> eventGenerator, Duration every, Consumer<PublishFailure> onError) CompletableFuture<akka.Done>
shutdown()
Shuts down the connection for this publisher.
-
Method Details
-
publish
Publish a singleEvent
At the time of invocation, in case the underlying server is not available,
EventServerNotAvailable
exception is thrown, in all other casesPublishFailure
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
Publish from a stream ofEvent
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 aPublishFailure
exception which wraps the underlying exception. The stream resumes to publish remaining elements in case of this exception.- Parameters:
source
- aSource
of events to be published- Returns:
- the materialized value obtained on running the stream
-
publish
Publish from a stream ofEvent
, and perform an operation defined usingonError
consumer for each event for which publishing failedAt 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 aPublishFailure
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
- aSource
of 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
PublishEvent
from aneventGenerator
supplier, which will be executed atevery
frequency.Cancellable
can be used to cancel the execution ofeventGenerator
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 aPublishFailure
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 atevery
frequencyevery
- 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) PublishEvent
from aneventGenerator
supplier, which will be started at the specifiedstartTime
and will be executed atevery
frequency.Cancellable
can be used to cancel the execution ofeventGenerator
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 aPublishFailure
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 atevery
frequencystartTime
- the time at which theeventGenerator
should 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(Supplier<Optional<Event>> eventGenerator, Duration every, Consumer<PublishFailure> onError) PublishEvent
from aneventGenerator
supplier, which will be executed atevery
frequency. Also, provideonError
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 aPublishFailure
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 atevery
frequencyevery
- 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(Supplier<Optional<Event>> eventGenerator, TMTTime startTime, Duration every, Consumer<PublishFailure> onError) PublishEvent
from aneventGenerator
supplier, which will be started at the specifiedstartTime
and will be executed atevery
frequency. Also, provideonError
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 aPublishFailure
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 atevery
frequencystartTime
- the time at which theeventGenerator
should 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(Supplier<CompletableFuture<Optional<Event>>> eventGenerator, Duration every) PublishEvent
from aneventGenerator
supplier, which will be executed atevery
frequency.Cancellable
can be used to cancel the execution ofeventGenerator
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 aPublishFailure
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 atevery
frequencyevery
- 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) PublishEvent
from aneventGenerator
supplier, which will be started at the specifiedstartTime
and will be executed atevery
frequency. Also, provideonError
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 aPublishFailure
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 atevery
frequencystartTime
- the time at which theeventGenerator
should 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(Supplier<CompletableFuture<Optional<Event>>> eventGenerator, Duration every, Consumer<PublishFailure> onError) PublishEvent
from aneventGenerator
supplier, which will be executed atevery
frequency. Also, provideonError
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 aPublishFailure
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 atevery
frequencyevery
- 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(Supplier<CompletableFuture<Optional<Event>>> eventGenerator, TMTTime startTime, Duration every, Consumer<PublishFailure> onError) PublishEvent
from aneventGenerator
supplier, which will be started at the specifiedstartTime
and will be executed atevery
frequency. Also, provideonError
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 aPublishFailure
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 atevery
frequencystartTime
- the time at which theeventGenerator
should 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
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
-