Class DefaultRequestHandler

java.lang.Object
io.fluxcapacitor.javaclient.publishing.DefaultRequestHandler
All Implemented Interfaces:
RequestHandler, AutoCloseable

public class DefaultRequestHandler extends Object implements RequestHandler
Default implementation of the RequestHandler interface.

This handler supports both single and batch request dispatching, tracking responses using an internal ConcurrentHashMap keyed by requestId. When a request is sent, the handler subscribes to a corresponding result log (e.g., result or web response) via a TrackingClient, which listens for responses targeted at this client only.

Each request is assigned a unique requestId and tagged with the client's source identifier. When a response with a matching requestId is received, the corresponding CompletableFuture is completed.

If no response is received within the configured timeout (default: 200 seconds), the future is completed exceptionally.

This request handle supports chunked responses. Request senders that can deal with chunked responses should use sendRequest(SerializedMessage, Consumer, Duration, Consumer)}. If a chunked response is received, but the request sender expected a single response, the intermediate responses are aggregated before completing the request.

Features:

  • Supports both single and batch request dispatching.
  • Tracks responses via the configured MessageType and filters using filterMessageTarget = true.
  • Ensures startup of the underlying result tracker on first request dispatch.
  • Cleans up subscriptions and pending futures on close().
See Also: