EventRouting

public final class EventRouting<I> extends MessageRouting<M, C, R> implements EventRoute<I, M>

A routing schema used to deliver events.

A routing schema consists of a default route and custom routes per event class. When calculating a set of event targets, EventRouting will see if there is a custom route set for the type of the event. If not found, the default route will be applied.

Parameters

<I>

the type of the entity IDs to which events are routed

Functions

Link copied to clipboard
public final EventRoute<I, EventMessage> defaultRoute()
Obtains the default route used by the schema.
Link copied to clipboard
public Optional<EventRoute<I, M>> get<M extends EventMessage>(Class<M> eventClass)
Obtains a route for the passed event class.
Link copied to clipboard
public EventRouting<I> replaceDefault(EventRoute<I, EventMessage> newDefault)
Sets new default route in the schema.
Link copied to clipboard
public EventRouting<I> route<E extends EventMessage>(Class<E> eventType, EventRoute<I, ? extends Object> via)
Sets a custom route for the passed event type.
Link copied to clipboard
Sets a custom routing schema for entity state updates.
Link copied to clipboard
public EventRouting<I> unicast<E extends EventMessage>(Class<E> eventType, BiFunction<E, EventContext, I> via)
Sets a custom route for the passed event type by obtaining the target entity ID from the passed function over event message and its context.
public EventRouting<I> unicast<E extends EventMessage>(Class<E> eventType, Function<E, I> via)
Sets a custom route for the passed event type by obtaining the target entity ID from the passed function.
Link copied to clipboard
public static EventRouting<I> withDefault<I>(EventRoute<I, EventMessage> defaultRoute)
Creates a new event routing with the passed default route.
Link copied to clipboard
Creates a new event routing with the default one by event producer ID.

Inherited functions

Link copied to clipboard
public BiFunction<T, U, V> andThen<V>(Function<? extends Object, ? extends V> after)
Link copied to clipboard
public R apply(M message, C context)
Obtains IDs of entities to which the passed message should be delivered.
public abstract R apply(T p, U p1)
Link copied to clipboard
public static EventRoute<I, EventMessage> byFirstMessageField<I>(Class<I> idClass)
Creates an event route that obtains event producer ID from an EventContext and returns it as a sole element of the immutable set.
Link copied to clipboard
public static EventRoute<I, EventMessage> byProducerId<I>()
Creates an event route that obtains event producer ID from an EventContext and returns it as a sole element of the immutable set.
Link copied to clipboard
public static Set<I> noTargets<I>()
Returns the empty immutable set.
Link copied to clipboard
public void remove(Class<? extends M> messageClass)
Removes a route for the passed message class.
Link copied to clipboard
public boolean supports(Class<? extends M> messageType)
Checks if the passed message type is supported by this instance of routing.
Link copied to clipboard
public static Set<I> withId<I>(I id)
Creates an immutable singleton set with the passed ID.