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.

@FunctionalInterface public interface LocalQueryDispatchPredicate
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 Type
    Method
    Description
    boolean
    Indicates whether the given query should be dispatched to the local segment directly, rather than being routed through the connector.
  • Method Details

    • shouldDispatchLocally

      boolean shouldDispatchLocally(QueryMessage query, @Nullable ProcessingContext context)
      Indicates whether the given query should be dispatched to the local segment directly, rather than being routed through the connector.
      Parameters:
      query - the query message about to be dispatched
      context - the processing context active for the dispatch, or null when the query is dispatched outside of an existing processing context
      Returns:
      true to attempt to dispatch the query to the local segment, false to route it through the connector as usual