Event Bus
Dispatches incoming events to subscribers and provides ways for registering those subscribers.
Receiving Events
To receive event messages, a subscriber object should:
- Expose a
public
method that accepts an event message as the first parameter and an EventContext as the second (optional) parameter. - Mark the method with the @Subscribe annotation.
- register Register} with an instance of
EventBus
directly or rely on message delivery from an EventDispatcher. An example of such a dispatcher is ProjectionRepository.
Note: A subscriber method cannot accept just Message as the first parameter. It must be an exact type of the event message that needs to be handled.
Posting Events
Events are posted to an EventBus using post method. Normally this is done by an AggregateRepository in the process of handling a command or by a ProcessManager.
The passed Event is stored in the EventStore associated with the EventBus
before it is passed to subscribers.
If there are no subscribers or dispatchers for the posted event, the fact is logged as warning with no further processing.
See also
Projection
io. spine. core. Subscribe
@Subscribe
Types
Functions
Link copied to clipboard
Obtains the instance of DeadMessageHandler for this bus.
Link copied to clipboard
Passes the given envelope for dispatching.
Link copied to clipboard
Returns EventStore associated with the bus.
Link copied to clipboard
Determines if this instance is already registered with a Bounded Context.
Link copied to clipboard
Creates a builder for new
EventBus
.Link copied to clipboard
Obtains the view
Set
of events that are known to this EventBus
.Link copied to clipboard
Registers this instance as a part of the given Bounded Context.
Link copied to clipboard
Packs the given message of type
T
into an envelope of type E
.Link copied to clipboard
Obtains the instance of EnvelopeValidator for this bus.
Inherited functions
Link copied to clipboard
Call the dispatchers for the
messageEnvelope
.Link copied to clipboard
Verifies that this instance is NOT registered yet.
Link copied to clipboard
Verifies that this instance is already registered.
Link copied to clipboard
Link copied to clipboard
Called after the dispatching of the signal to all of the target dispatchers has been completed.
Link copied to clipboard
Called before the dispatching of the signal with the passed ID is started.
Link copied to clipboard
Prepares the given StreamObserver to post messages into this bus.
Link copied to clipboard
Link copied to clipboard
Unregisters dispatching for message classes of the passed dispatcher.