Interface LocalQueryDispatchPredicate
- 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
QueryMessage that is about to be dispatched through a QueryBusConnector
should be handled by the local segment directly (taking a "local shortcut") instead of being routed by the connector,
which may hand the query to a different segment.
Registering an implementation of this functional interface activates the LocalShortcutQueryBusConnector
automatically.
The predicate is consulted for every outgoing
direct query, but
only takes effect when the local segment actually subscribed a handler for the query. When it did not, the query is
routed as usual regardless of this predicate's outcome. Subscription queries are never shortcut and never
consult this predicate as their update registrations must be coordinated across all nodes.
- Since:
- 5.4.0
- Author:
- Allard Buijze
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbooleanshouldDispatchLocally(QueryMessage query, @Nullable ProcessingContext context) Indicates whether the givenqueryshould be dispatched to the local segment directly, rather than being routed through the connector.
-
Method Details
-
shouldDispatchLocally
Indicates whether the givenqueryshould be dispatched to the local segment directly, rather than being routed through the connector.- Parameters:
query- the query message about to be dispatchedcontext- the processing context active for the dispatch, ornullwhen the query is dispatched outside of an existing processing context- Returns:
trueto attempt to dispatch the query to the local segment,falseto route it through the connector as usual
-