Interface RequestHandler

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
DefaultRequestHandler

public interface RequestHandler extends AutoCloseable
Handles the lifecycle of request/response interactions in a Flux Capacitor client.

A RequestHandler is responsible for sending requests—such as commands, queries, or web requests— and asynchronously completing them when a corresponding response is received. Requests may be handled locally or remotely via the Flux platform.

Handling Strategies

  • Local Handling: If a request matches a locally registered handler, the RequestHandler may invoke it directly. The result is either returned immediately or asynchronously via a CompletableFuture.
  • Remote Handling: If the request is dispatched to the Flux platform, the handler listens for the corresponding response via a TrackingClient subscribed to the appropriate result log (e.g. result or web response log). Responses are correlated using a unique requestId embedded in each SerializedMessage.

To prevent unnecessary message traffic, the underlying tracker is typically configured with:

  • filterMessageTarget = true, so only messages targeted to this client are delivered.
  • clientControlledIndex = true, allowing precise control over result consumption.

A RequestHandler implementation must ensure lifecycle management, including resource cleanup and deregistration when close() is invoked.