Follow-up · depth 11
How do you make CompletableFuture Composition safer under partial failure?
How do you make CompletableFuture Composition safer under partial failure?
Answers use simple, clear English.
Quick interview answer
Harden CompletableFuture Composition with timeouts, retries with jitter, isolation, and graceful degradation. Use CompletableFuture Composition as the core idea. Example shape: Aggregate microservice responses: CompletableFuture.allOf(userF, ordersF).thenApply(...)..
Detailed answer
Resilience for CompletableFuture Composition under partial failure: • Timeouts + budgets on every dependency call • Retries only when idempotent, with jitter/backoff • Isolation: bulkheads/queues so one failure does not cascade • Degradation: serve stale/cached/limited mode when needed Practices: Specify executor for IO; use orTimeout/join with timeout in Java 9+. Parent context: Use CompletableFuture Composition as the core idea. Example shape: Aggregate microservice responses: CompletableFuture.allOf(userF, ordersF).thenApply(...)..
Full explanation
Partial failure is the default in distributed systems — show how CompletableFuture Composition stays useful anyway. supplyAsync runs async task; thenApply transforms; thenCompose flattens nested futures; allOf waits for batch. Exceptionally/handle for error paths.
Follow-up questions
Only answered follow-ups are shown — click to open with full answers
Parent context — CompletableFuture Composition
Use CompletableFuture Composition as the core idea. Example shape: Aggregate microservice responses: CompletableFuture.allOf(userF, ordersF).thenApply(...)..
View full parent question →