Interface RequestHandler

All Superinterfaces:
AutoCloseable, Namespaced<RequestHandler>
All Known Implementing Classes:
DefaultRequestHandler

public interface RequestHandler extends Namespaced<RequestHandler>, AutoCloseable
Handles the lifecycle of request/response interactions in a Fluxzero 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 Fluxzero Runtime.

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 Fluxzero Runtime, 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.

  • Field Details

    • REQUEST_TIMEOUT_METADATA_KEY

      static final String REQUEST_TIMEOUT_METADATA_KEY
      Metadata key containing the effective request timeout in milliseconds.

      Request handler implementations set this metadata while dispatching timed requests. Tracking handlers use it to determine whether an indexed request has already expired before invoking the handler.

      See Also:
  • Method Details