public interface IEventPublisher
EventKey
in the Event
model. This key can be used by the subscribers using IEventSubscriber
interface to subscribe to the events.Modifier and Type | Method and Description |
---|---|
java.util.concurrent.CompletableFuture<akka.Done> |
publish(Event event)
Publish a single
Event |
<Mat> Mat |
publish(akka.stream.javadsl.Source<Event,Mat> source)
Publish from a stream of
Event |
<Mat> Mat |
publish(akka.stream.javadsl.Source<Event,Mat> source,
java.util.function.Consumer<PublishFailure> onError)
Publish from a stream of
Event , and perform an operation defined using onError consumer for each event
for which publishing failed |
akka.actor.Cancellable |
publish(java.util.function.Supplier<Event> eventGenerator,
java.time.Duration every)
|
akka.actor.Cancellable |
publish(java.util.function.Supplier<Event> eventGenerator,
java.time.Duration every,
java.util.function.Consumer<PublishFailure> onError)
|
akka.actor.Cancellable |
publishAsync(java.util.function.Supplier<java.util.concurrent.CompletableFuture<Event>> eventGenerator,
java.time.Duration every)
|
akka.actor.Cancellable |
publishAsync(java.util.function.Supplier<java.util.concurrent.CompletableFuture<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.
|
java.util.concurrent.CompletableFuture<akka.Done> publish(Event event)
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
event
- an event to be published<Mat> Mat publish(akka.stream.javadsl.Source<Event,Mat> source)
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.
source
- a Source
of events to be published<Mat> Mat publish(akka.stream.javadsl.Source<Event,Mat> source, java.util.function.Consumer<PublishFailure> onError)
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.
source
- a Source
of events to be publishedonError
- a consumer which defines an operation for each event for which publishing failedakka.actor.Cancellable publish(java.util.function.Supplier<Event> eventGenerator, java.time.Duration every)
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.
eventGenerator
- a supplier which can generate an event to be published at every
frequencyevery
- frequency with which the events are to be publishedeventGenerator
akka.actor.Cancellable publish(java.util.function.Supplier<Event> eventGenerator, java.time.Duration every, java.util.function.Consumer<PublishFailure> onError)
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.
eventGenerator
- a function which can generate an event to be published at every
frequencyevery
- frequency with which the events are to be publishedonError
- a consumer which defines an operation for each event for which publishing failedeventGenerator
akka.actor.Cancellable publishAsync(java.util.function.Supplier<java.util.concurrent.CompletableFuture<Event>> eventGenerator, java.time.Duration every)
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.
eventGenerator
- a supplier which can generate Future of event to be published at every
frequencyevery
- frequency with which the events are to be publishedeventGenerator
akka.actor.Cancellable publishAsync(java.util.function.Supplier<java.util.concurrent.CompletableFuture<Event>> eventGenerator, java.time.Duration every, java.util.function.Consumer<PublishFailure> onError)
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.
eventGenerator
- a function which can generate Future of event to be published at every
frequencyevery
- frequency with which the events are to be publishedonError
- a consumer which defines an operation for each event for which publishing failedeventGenerator
java.util.concurrent.CompletableFuture<akka.Done> shutdown()
Any exception that occurs will cause the future to complete with a Failure.