ImportBus

public final class ImportBus extends UnicastBus<T, E, C, D>

Dispatches events to repositories of aggregates that import these events.

Usage Scenarios

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:

  1. serves as a dispatched message type which is used as the first argument of the corresponding aggregate handler method;
  2. carries the information about the fact we want to remember.

Marking events and ensuring proper routing allows to store aggregate events without having intermediate messages.

Temporal Logic

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.

Types

Link copied to clipboard
public class Builder extends BusBuilder<B, T, E, C, D>
The builder for ImportBus.

Functions

Link copied to clipboard
Obtains the instance of DeadMessageHandler for this bus.
Link copied to clipboard
protected void dispatch(EventEnvelope event)
Passes the given envelope for dispatching.
Link copied to clipboard
public static ImportBus.Builder newBuilder()
Creates a builder for creating a new ImportBus.
Link copied to clipboard
protected ImportBus.Registry registry()
Obtains the dispatcher registry.
Link copied to clipboard
protected void store(Iterable<Event> events)
Updates the TenantIndex with the ID obtained from the passed events.
Link copied to clipboard
protected EventEnvelope toEnvelope(Event wrapper)
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
public void checkOpen()
Ensures that the object is open.
Link copied to clipboard
public void close()
Closes the filters of this bus and unregisters all the dispatchers.
public abstract void close()
Link copied to clipboard
protected D dispatcherOf(E envelope)
Link copied to clipboard
public boolean hasFilter(BusFilter<E> filter)
Link copied to clipboard
public boolean hasListener(Listener<E> listener)
Link copied to clipboard
public final boolean isOpen()
Tells if this bus can accept messages for posting.
Link copied to clipboard
protected void onDispatched(SignalId signal)
Called after the dispatching of the signal to all of the target dispatchers has been completed.
Link copied to clipboard
protected void onDispatchingStarted(SignalId signal)
Called before the dispatching of the signal with the passed ID is started.
Link copied to clipboard
public final void post(T message, StreamObserver<Ack> observer)
Posts the message to the bus.
public final void post(Iterable<T> messages, StreamObserver<Ack> observer)
Posts the given messages to the bus.
Link copied to clipboard
protected StreamObserver<Ack> prepareObserver(Iterable<T> messages, StreamObserver<Ack> source)
Prepares the given StreamObserver to post messages into this bus.
Link copied to clipboard
public void register(D dispatcher)
Registers the passed dispatcher.
Link copied to clipboard
A callback for derived classes to modify the order of filters used by the bus.
Link copied to clipboard
public void unregister(D dispatcher)
Unregisters dispatching for message classes of the passed dispatcher.