public static class DefaultEventDispatcher.Builder extends Object implements EventDispatcher.Builder
EventDispatcher
instances.Modifier and Type | Field and Description |
---|---|
protected FluxProcessor<Event,Event> |
eventProcessor |
protected Scheduler |
eventScheduler |
protected FluxSink.OverflowStrategy |
overflowStrategy |
Modifier | Constructor and Description |
---|---|
protected |
Builder() |
Modifier and Type | Method and Description |
---|---|
EventDispatcher |
build()
Create the
EventDispatcher |
DefaultEventDispatcher.Builder |
eventProcessor(FluxProcessor<Event,Event> eventProcessor)
Set the underlying
FluxProcessor the dispatcher will use to queue and distribute events. |
DefaultEventDispatcher.Builder |
eventScheduler(Scheduler eventScheduler)
Set the
Scheduler this dispatcher should use to publish events to its subscribers. |
DefaultEventDispatcher.Builder |
overflowStrategy(FluxSink.OverflowStrategy overflowStrategy)
Set the
FluxSink.OverflowStrategy for dealing with overflow scenarios where too many events are
being published. |
protected FluxProcessor<Event,Event> eventProcessor
protected FluxSink.OverflowStrategy overflowStrategy
protected Scheduler eventScheduler
public DefaultEventDispatcher.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
- the custom processor for eventspublic DefaultEventDispatcher.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
- the custom backpressure strategypublic DefaultEventDispatcher.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
- a custom Scheduler
to publish eventspublic EventDispatcher build()
EventDispatcher.Builder
EventDispatcher
build
in interface EventDispatcher.Builder
EventDispatcher
with the configured parameters.