public abstract class AbstractEventBus extends Object implements EventBus
This implementation of the EventBus directly forwards all published events (in the callers' thread) to
subscribed event processors. Event processors are expected to implement asynchronous handling themselves or
alternatively open an event stream using EventBus.openStream(TrackingToken).
| Constructor and Description |
|---|
AbstractEventBus()
Initializes an event bus with a
NoOpMessageMonitor. |
AbstractEventBus(MessageMonitor<? super EventMessage<?>> messageMonitor)
Initializes an event bus.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
afterCommit(List<? extends EventMessage<?>> events)
Process given
events after the Unit of Work has been committed. |
protected void |
commit(List<? extends EventMessage<?>> events)
Process given
events while the Unit of Work root is being committed. |
protected List<? extends EventMessage<?>> |
intercept(List<? extends EventMessage<?>> events)
Invokes all the dispatch interceptors.
|
protected void |
prepareCommit(List<? extends EventMessage<?>> events)
Process given
events while the Unit of Work root is preparing for commit. |
void |
publish(List<? extends EventMessage<?>> events)
Publish a collection of events on this bus (one, or multiple).
|
protected List<EventMessage<?>> |
queuedMessages()
Returns a list of all the events staged for publication in this Unit of Work.
|
Registration |
registerDispatchInterceptor(MessageDispatchInterceptor<EventMessage<?>> dispatchInterceptor)
Register the given
interceptor with this bus. |
Registration |
subscribe(Consumer<List<? extends EventMessage<?>>> eventProcessor)
Subscribe the given
messageProcessor to this message source. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitopenStream, publishpublic AbstractEventBus()
NoOpMessageMonitor.public AbstractEventBus(MessageMonitor<? super EventMessage<?>> messageMonitor)
messageMonitor to report ingested messages and report the
result of processing the message.messageMonitor - The monitor used to monitor the ingested messagespublic Registration subscribe(Consumer<List<? extends EventMessage<?>>> eventProcessor)
SubscribableMessageSourcemessageProcessor to this message source. When subscribed, it will receive all
messages published to this source.
If the given messageProcessor is already subscribed, nothing happens.
subscribe in interface SubscribableMessageSource<EventMessage<?>>eventProcessor - The message processor to subscribemessageProcessor. When unsubscribed it will no longer receive
messages.public Registration registerDispatchInterceptor(MessageDispatchInterceptor<EventMessage<?>> dispatchInterceptor)
interceptor with this bus. When subscribed it will intercept any event messages
published on this bus.
If the given interceptor is already registered, nothing happens.
preprocessor is not invoked by this Event Bus until the Unit
of Work root is committed.registerDispatchInterceptor in interface EventBusdispatchInterceptor - dispatchInterceptor. When unregistered it will no longer be given
event messages published on this bus.public void publish(List<? extends EventMessage<?>> events)
EventBus
Implementations may treat the given events as a single batch and distribute the events as such to
all subscribed EventListeners.
protected List<EventMessage<?>> queuedMessages()
protected List<? extends EventMessage<?>> intercept(List<? extends EventMessage<?>> events)
events - The original events being publishedprotected void prepareCommit(List<? extends EventMessage<?>> events)
events while the Unit of Work root is preparing for commit. The default implementation
signals the registered MessageMonitor that the given events are ingested and passes the events to each
registered event processor.events - Events to be published by this Event Busprotected void commit(List<? extends EventMessage<?>> events)
events while the Unit of Work root is being committed. The default implementation does
nothing.events - Events to be published by this Event Busprotected void afterCommit(List<? extends EventMessage<?>> events)
events after the Unit of Work has been committed. The default implementation does
nothing.events - Events to be published by this Event BusCopyright © 2010–2017. All rights reserved.