public interface EventBus extends SubscribableMessageSource<EventMessage<?>>, StreamableMessageSource<TrackedEventMessage<?>>
EventListener
,
SimpleEventBus
Modifier and Type | Method and Description |
---|---|
TrackingEventStream |
openStream(TrackingToken trackingToken)
Open an event stream containing all events since given tracking token.
|
default void |
publish(EventMessage<?>... events)
Publish a collection of events on this bus (one, or multiple).
|
void |
publish(List<? extends EventMessage<?>> events)
Publish a collection of events on this bus (one, or multiple).
|
Registration |
registerDispatchInterceptor(MessageDispatchInterceptor<EventMessage<?>> dispatchInterceptor)
Register the given
interceptor with this bus. |
subscribe
TrackingEventStream openStream(TrackingToken trackingToken)
trackingToken
of null
to open a
stream containing all available events. Note that the returned stream is infinite, so beware of applying
terminal operations to the returned stream.
In case the event bus cannot open a stream for a given tracking token, for instance because the event bus does
not persist or cache events, the event bus will throw an UnsupportedOperationException
.
openStream
in interface StreamableMessageSource<TrackedEventMessage<?>>
trackingToken
- object describing the previous position in the stream or null
to create a
stream of all eventsTrackingEventStream
with events since the given trackingTokenUnsupportedOperationException
- in case this event bus does not support streaming from given tokendefault void publish(EventMessage<?>... events)
Implementations may treat the given events
as a single batch and distribute the events as such to
all subscribed EventListeners.
events
- The collection of events to publishvoid publish(List<? extends EventMessage<?>> events)
Implementations may treat the given events
as a single batch and distribute the events as such to
all subscribed EventListeners.
events
- The collection of events to publishRegistration 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.
dispatchInterceptor
- The event message dispatch interceptor to registerdispatchInterceptor
. When unregistered it will no longer be given
event messages published on this bus.Copyright © 2010–2017. All rights reserved.