Package com.couchbase.client.core.cnc
Class DefaultEventBus
java.lang.Object
com.couchbase.client.core.cnc.DefaultEventBus
- All Implemented Interfaces:
EventBus
The
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!
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Allows to modify the default configuration of theDefaultEventBus
.Nested classes/interfaces inherited from interface com.couchbase.client.core.cnc.EventBus
EventBus.PublishResult
-
Method Summary
Modifier and TypeMethodDescriptionstatic DefaultEventBus.Builder
static DefaultEventBus
Try to publish an event.start()
Starts theDefaultEventBus
.Stops theDefaultEventBus
from running.void
unsubscribe
(EventSubscription subscription)
-
Method Details
-
builder
-
create
-
subscribe
Description copied from interface:EventBus
- Specified by:
subscribe
in interfaceEventBus
- Parameters:
consumer
- the consumer which will receive events.- Returns:
- a
EventSubscription
that can be used to unsubscribe.
-
unsubscribe
Description copied from interface:EventBus
- Specified by:
unsubscribe
in interfaceEventBus
- Parameters:
subscription
- the subscription used.
-
publish
Description copied from interface:EventBus
Try to publish an event.- Specified by:
publish
in interfaceEventBus
- Parameters:
event
- the event to publish.- Returns:
- the
EventBus.PublishResult
of th event.
-
start
Starts theDefaultEventBus
. -
stop
Stops theDefaultEventBus
from running.
-