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.

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

    • shouldDispatchLocally

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