Interface FutureResolver

All Known Implementing Classes:
DefaultTimeoutFutureResolver
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 FutureResolver
Resolves a CompletableFuture according to a configurable waiting policy.

Applications can provide one implementation through Java's ServiceLoader mechanism or a configuration component to replace the default resolver. The configured resolver is used wherever workflow code waits for a future. When no component is present, DefaultTimeoutFutureResolver applies a 30-second safety-net timeout. This is sufficient for synchronous in-memory, local database, and unit-of-work operations while surfacing hung dependencies before they exhaust workflow threads. Callers that legitimately expect a longer wait must configure a resolver with that bound.

Since:
5.4.0
Author:
Simon Zambrovski
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Resolves the given future according to this resolver's policy.
    static void
    resolve(ProcessingContext processingContext, CompletableFuture<?> future)
    Resolves a future through the resolver registered in the processing context.
  • Method Details

    • resolve

      static void resolve(ProcessingContext processingContext, CompletableFuture<?> future)
      Resolves a future through the resolver registered in the processing context.

      A default resolver is used as a fallback for contexts created in tests or outside configured workflow processing. A resolver timeout is always exposed as a FutureResolutionTimeoutException; this prevents it from being interpreted as a workflow timeout.

      Parameters:
      processingContext - context containing the configured resolver
      future - future to resolve
    • resolve

      void resolve(CompletableFuture<?> future)
      Resolves the given future according to this resolver's policy.

      Implementations should throw FutureResolutionTimeoutException when their resolution timeout expires. The context-based resolve(ProcessingContext, CompletableFuture) overload also normalizes a raw TimeoutException for implementations that cannot yet do so.

      Parameters:
      future - future to resolve