public static class ReplayingEventDispatcher.Builder extends DefaultEventDispatcher.Builder
EventDispatcher
instances.Modifier and Type | Field and Description |
---|---|
protected Predicate<Event> |
replayEventFilter |
protected FluxSink.OverflowStrategy |
replayEventOverflowStrategy |
protected ReplayProcessor<Event> |
replayEventProcessor |
protected Publisher<?> |
stopReplayingTrigger |
protected Scheduler |
timedTaskScheduler |
eventProcessor, eventScheduler, overflowStrategy
Modifier | Constructor and Description |
---|---|
protected |
Builder() |
Modifier and Type | Method and Description |
---|---|
EventDispatcher |
build()
Create the
EventDispatcher |
ReplayingEventDispatcher.Builder |
eventProcessor(FluxProcessor<Event,Event> eventProcessor)
Set the underlying
FluxProcessor the dispatcher will use to queue and distribute events. |
ReplayingEventDispatcher.Builder |
eventScheduler(Scheduler eventScheduler)
Set the
Scheduler this dispatcher should use to publish events to its subscribers. |
ReplayingEventDispatcher.Builder |
overflowStrategy(FluxSink.OverflowStrategy overflowStrategy)
Set the
FluxSink.OverflowStrategy for dealing with overflow scenarios where too many events are
being published. |
ReplayingEventDispatcher.Builder |
replayEventFilter(Predicate<Event> replayEventFilter)
Set a filter used to determine whether an incoming
Event should be stored for replay. |
ReplayingEventDispatcher.Builder |
replayEventOverflowStrategy(FluxSink.OverflowStrategy replayEventOverflowStrategy)
Set an overflow strategy while pushing events to the replay processor.
|
ReplayingEventDispatcher.Builder |
replayEventProcessor(ReplayProcessor<Event> replayEventProcessor)
Set a processor used to store events while no subscribers are connected and will be forwarded to all late
subscribers.
|
ReplayingEventDispatcher.Builder |
stopReplayingTrigger(Publisher<?> stopReplayingTrigger)
Set a trigger
Publisher that is subscribed upon the first subscriber connects to this dispatcher. |
ReplayingEventDispatcher.Builder |
timedTaskScheduler(Scheduler timedTaskScheduler)
Set a time-capable
Scheduler used to detect whether all events have replayed to a subscriber. |
protected Scheduler timedTaskScheduler
protected ReplayProcessor<Event> replayEventProcessor
protected FluxSink.OverflowStrategy replayEventOverflowStrategy
protected Publisher<?> stopReplayingTrigger
public ReplayingEventDispatcher.Builder eventProcessor(FluxProcessor<Event,Event> eventProcessor)
EventDispatcher.Builder
FluxProcessor
the dispatcher will use to queue and distribute events. Defaults
to using an EmitterProcessor
.
Using EmitterProcessor
only emits events since a subscriber has subscribed to the processor
(except for the first one which receives all queued signals until that point), and it allows you to
configure the backing queue size while allowing you to use operators like Flux.repeat()
and
Flux.retry()
to drop the triggering signal.
eventProcessor
in interface EventDispatcher.Builder
eventProcessor
in class DefaultEventDispatcher.Builder
eventProcessor
- the custom processor for eventspublic ReplayingEventDispatcher.Builder overflowStrategy(FluxSink.OverflowStrategy overflowStrategy)
EventDispatcher.Builder
FluxSink.OverflowStrategy
for dealing with overflow scenarios where too many events are
being published. Defaults to using FluxSink.OverflowStrategy#BUFFER
to ensure all events are
delivered at the cost of higher memory footprint and potential OutOfMemoryError
scenarios.
To only keep the earliest events you can use FluxSink.OverflowStrategy#DROP
, and to only keep the
most recent events, use FluxSink.OverflowStrategy#LATEST
. The number of events that can be queued
until this strategy is applied depends on the underlying processor implementation.
overflowStrategy
in interface EventDispatcher.Builder
overflowStrategy
in class DefaultEventDispatcher.Builder
overflowStrategy
- the custom backpressure strategypublic ReplayingEventDispatcher.Builder eventScheduler(Scheduler eventScheduler)
EventDispatcher.Builder
Scheduler
this dispatcher should use to publish events to its subscribers. Using a bounded
elastic/blocking-capable one is recommended for general workloads that may have blocking sequences.eventScheduler
in interface EventDispatcher.Builder
eventScheduler
in class DefaultEventDispatcher.Builder
eventScheduler
- a custom Scheduler
to publish eventspublic ReplayingEventDispatcher.Builder replayEventProcessor(ReplayProcessor<Event> replayEventProcessor)
replayEventProcessor
- the replay processor to use as backendpublic ReplayingEventDispatcher.Builder replayEventOverflowStrategy(FluxSink.OverflowStrategy replayEventOverflowStrategy)
replayEventOverflowStrategy
- the strategy to use when pushing values to the replay processorpublic ReplayingEventDispatcher.Builder replayEventFilter(Predicate<Event> replayEventFilter)
Event
should be stored for replay.replayEventFilter
- the filter for events that can be replayedpublic ReplayingEventDispatcher.Builder timedTaskScheduler(Scheduler timedTaskScheduler)
Scheduler
used to detect whether all events have replayed to a subscriber.timedTaskScheduler
- the scheduler to detect no more events can be replayedpublic ReplayingEventDispatcher.Builder stopReplayingTrigger(Publisher<?> stopReplayingTrigger)
Publisher
that is subscribed upon the first subscriber connects to this dispatcher.
Upon completion, error or cancellation, the replaying window will be closed until all subscribers have
disconnected.stopReplayingTrigger
- the sequence to signal that no more events should be replayed. Can be
subscribed to multiple times as subscribers disconnect.public EventDispatcher build()
EventDispatcher.Builder
EventDispatcher
build
in interface EventDispatcher.Builder
build
in class DefaultEventDispatcher.Builder
EventDispatcher
with the configured parameters.