public class DefaultEventBus extends Object implements EventBus
DefaultEventBus
provides the default and very efficient implementation
of the EventBus
.
It is built on top of a very fast, bounded MPSC (multi-producer single-consumer) queue which allows to quickly send events into the bus without blocking the sender.
Subscribers of this API are considered to be non-blocking and if they have to blocking tasks need to fan them out into their own thread pool.
Keep in mind to properly start()
and stop(Duration)
since it runs in its
own thread!
Modifier and Type | Class and Description |
---|---|
static class |
DefaultEventBus.Builder
Allows to modify the default configuration of the
DefaultEventBus . |
EventBus.PublishResult
Modifier and Type | Method and Description |
---|---|
static DefaultEventBus.Builder |
builder(Scheduler scheduler) |
static DefaultEventBus |
create(Scheduler scheduler) |
EventBus.PublishResult |
publish(Event event)
Try to publish an event.
|
Mono<Void> |
start()
Starts the
DefaultEventBus . |
Mono<Void> |
stop(Duration timeout)
Stops the
DefaultEventBus from running. |
EventSubscription |
subscribe(Consumer<Event> consumer)
|
void |
unsubscribe(EventSubscription subscription)
|
public static DefaultEventBus.Builder builder(Scheduler scheduler)
public static DefaultEventBus create(Scheduler scheduler)
public EventSubscription subscribe(Consumer<Event> consumer)
EventBus
subscribe
in interface EventBus
consumer
- the consumer which will receive events.EventSubscription
that can be used to unsubscribe.public void unsubscribe(EventSubscription subscription)
EventBus
unsubscribe
in interface EventBus
subscription
- the subscription used.public EventBus.PublishResult publish(Event event)
EventBus
publish
in interface EventBus
event
- the event to publish.EventBus.PublishResult
of th event.public Mono<Void> start()
DefaultEventBus
.Copyright © 2020 Couchbase, Inc.. All rights reserved.