Interface LocalCommandDispatchPredicate
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Predicate deciding whether a
CommandMessage that is about to be dispatched through a
CommandBusConnector should be handled by the local segment directly (taking a "local shortcut") instead of
being routed by the connector, which might hand the command to a different segment.
Registering an implementation of this functional interface activates the LocalShortcutCommandBusConnector
automatically.
The predicate is consulted for every outgoing dispatch, but only takes effect when the local segment actually subscribed a handler for the command. When it did not, the command is routed as usual regardless of this predicate's outcome.
- Since:
- 5.4.0
- Author:
- Allard Buijze
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbooleanshouldDispatchLocally(CommandMessage command, @Nullable ProcessingContext context) Indicates whether the givencommandshould be dispatched to the local segment directly, rather than being routed through the connector.
-
Method Details
-
shouldDispatchLocally
Indicates whether the givencommandshould be dispatched to the local segment directly, rather than being routed through the connector.- Parameters:
command- the command message about to be dispatchedcontext- the processing context active for the dispatch, ornullwhen the command is dispatched outside of an existing processing context- Returns:
trueto attempt to dispatch the command to the local segment,falseto route it through the connector as usual
-