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.
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 TypeMethodDescriptionvoidresolve(CompletableFuture<?> future) Resolves the given future according to this resolver's policy.static voidresolve(ProcessingContext processingContext, CompletableFuture<?> future) Resolves a future through the resolver registered in the processing context.
-
Method Details
-
resolve
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 resolverfuture- future to resolve
-
resolve
Resolves the given future according to this resolver's policy.Implementations should throw
FutureResolutionTimeoutExceptionwhen their resolution timeout expires. The context-basedresolve(ProcessingContext, CompletableFuture)overload also normalizes a rawTimeoutExceptionfor implementations that cannot yet do so.- Parameters:
future- future to resolve
-