Interface HasLocalHandlers

All Known Subinterfaces:
CommandGateway, ErrorGateway, EventGateway, EventStore, GenericGateway, HandlerRegistry, MetricsGateway, QueryGateway, WebRequestGateway
All Known Implementing Classes:
DefaultCommandGateway, DefaultDocumentStore, DefaultErrorGateway, DefaultEventGateway, DefaultEventStore, DefaultGenericGateway, DefaultMessageScheduler, DefaultMetricsGateway, DefaultQueryGateway, DefaultWebRequestGateway, HandlerRegistry.MergedHandlerRegistry, HandlerRegistry.NoOpHandlerRegistry, LocalDocumentHandlerRegistry, LocalHandlerRegistry

public interface HasLocalHandlers
Base interface for gateways that support registering local message handlers.

Gateways that implement this interface can invoke message handlers directly in-memory, without involving the Flux platform. This is useful for scenarios where local responsiveness is critical or when the message is intended only for the current application.

Local handler registration is typically used for commands, queries, events, and other messages where in-process handling is desired. Handlers are registered per-target object, and can be selectively filtered using a HandlerFilter.

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Indicates whether any local handlers are currently registered for this gateway.
    default Registration
    Registers the given handler object and includes only the methods that are annotated with a recognized handler annotation (e.g., @HandleCommand, @HandleQuery, etc.).
    registerHandler(Object target, HandlerFilter handlerFilter)
    Registers a handler object, including only those methods that match the provided HandlerFilter.
    void
    Sets a custom filter to control whether a handler method is considered a local handler for the current application.
  • Method Details

    • registerHandler

      default Registration registerHandler(Object target)
      Registers the given handler object and includes only the methods that are annotated with a recognized handler annotation (e.g., @HandleCommand, @HandleQuery, etc.).

      This method uses LocalHandler to determine which methods to include. If a payload has an annotated handler like HandleQuery inside its class and the class is not annotated with TrackSelf, the handler is also considered to be local.

      Parameters:
      target - the object containing handler methods
      Returns:
      a Registration which can be used to unregister the handlers
    • hasLocalHandlers

      boolean hasLocalHandlers()
      Indicates whether any local handlers are currently registered for this gateway.
      Returns:
      true if local handlers are present, false otherwise
    • setSelfHandlerFilter

      void setSelfHandlerFilter(HandlerFilter selfHandlerFilter)
      Sets a custom filter to control whether a handler method is considered a local handler for the current application. This is typically used internally to ensure that handlers are associated with the correct application or component.
      Parameters:
      selfHandlerFilter - a HandlerFilter to apply to registered handlers
    • registerHandler

      Registration registerHandler(Object target, HandlerFilter handlerFilter)
      Registers a handler object, including only those methods that match the provided HandlerFilter.

      This method offers fine-grained control over which handler methods are registered, based on custom logic applied to method annotations and/or signatures.

      Parameters:
      target - the handler object containing annotated methods
      handlerFilter - the filter used to determine which methods should be registered
      Returns:
      a Registration which can be used to unregister the handlers