route
public EventRouting<I> route<E extends EventMessage>(Class<E> eventType, EventRoute<I, ? extends Object> via)
Sets a custom route for the passed event type.
Such mapping may be required for the following cases:
- An event message should be matched to more than one entity, for example, several projections updated in response to one event.
- The type of an event producer ID (stored in the event context) differs from the type of entity identifiers (
<I>
.
The type of the event can be a class or an interface. If a routing schema needs to contain entries for specific classes and an interface that these classes implement, routes for interfaces should be defined after entries for the classes:
customRouting.route(MyEventClass.class, (event, context) -> { ... })
.route(MyEventInterface.class, (event, context) -> { ... });
Content copied to clipboard
IllegalStateException
. If there is no specific route for an event type, the default route will be used.
Return
this
to allow chained calls when configuring the routing
Parameters
event Type
the type of events to route
via
the instance of the route to be used
<E>
the type of the event message
Throws
if the route for this event type is already set either directly or via a super-interface