public final class ImportBus extends UnicastBus<io.spine.core.Event,EventEnvelope,EventClass,EventImportDispatcher<?>>
Importing events may be used for registering facts occurred in a legacy or a third-party system, which the Bounded Context translates into facts (events) of its history.
Another scenario is registering facts occurred within a Bounded Context without having intermediate commands or events.
Adding an event to an aggregate history normally requires either a command (handling of which produces the event) or an event (reaction on which may produce the event). Such a command or an event:
Marking events and ensuring proper routing allows to store aggregate events without having intermediate messages.
Importing events through dispatching one or several events is designed for importing of events as they occur.
Importing events which occurred before the events already stored in the aggregate history may result in hard to track bugs, and is not recommended.
Modifier and Type | Class and Description |
---|---|
static class |
ImportBus.Builder
The builder for
ImportBus . |
Modifier and Type | Method and Description |
---|---|
protected DeadMessageHandler<EventEnvelope> |
deadMessageHandler()
Obtains the instance of
DeadMessageHandler for this bus. |
protected void |
dispatch(EventEnvelope event)
Passes the given envelope for dispatching.
|
static ImportBus.Builder |
newBuilder()
Creates a builder for creating a new
ImportBus . |
protected io.spine.server.aggregate.ImportBus.Registry |
registry()
Obtains the dispatcher registry.
|
protected void |
store(java.lang.Iterable<io.spine.core.Event> events)
Updates the
TenantIndex with the ID
obtained from the passed events. |
protected EventEnvelope |
toEnvelope(io.spine.core.Event wrapper)
Packs the given message of type
T into an envelope of type E . |
protected EnvelopeValidator<EventEnvelope> |
validator()
Obtains the instance of
EnvelopeValidator for this bus. |
dispatcherOf
close, hasFilter, hasListener, isOpen, onDispatched, onDispatchingStarted, post, post, prepareObserver, register, setupFilters, unregister
public static ImportBus.Builder newBuilder()
ImportBus
.protected DeadMessageHandler<EventEnvelope> deadMessageHandler()
Bus
DeadMessageHandler
for this bus.deadMessageHandler
in class Bus<io.spine.core.Event,EventEnvelope,EventClass,EventImportDispatcher<?>>
protected EnvelopeValidator<EventEnvelope> validator()
Bus
EnvelopeValidator
for this bus.validator
in class Bus<io.spine.core.Event,EventEnvelope,EventClass,EventImportDispatcher<?>>
protected EventEnvelope toEnvelope(io.spine.core.Event wrapper)
Bus
T
into an envelope of type E
.toEnvelope
in class Bus<io.spine.core.Event,EventEnvelope,EventClass,EventImportDispatcher<?>>
wrapper
- the message to packprotected void dispatch(EventEnvelope event)
Bus
Finds and invokes the MessageDispatcher(s) for the given message.
This method assumes that the given message has passed the filtering.
dispatch
in class Bus<io.spine.core.Event,EventEnvelope,EventClass,EventImportDispatcher<?>>
for the public API
protected io.spine.server.aggregate.ImportBus.Registry registry()
Bus
registry
in class Bus<io.spine.core.Event,EventEnvelope,EventClass,EventImportDispatcher<?>>
protected void store(java.lang.Iterable<io.spine.core.Event> events)
TenantIndex
with the ID
obtained from the passed events.store
in class Bus<io.spine.core.Event,EventEnvelope,EventClass,EventImportDispatcher<?>>
events
- the messages to store