0
votes

I have a scenario where I call an external web service from my REST API using Spring Async. It returns a CompletableFuture and it is clear that we can wait for a time till external async operation completes. Main thread returns with Status 202 when timeout occurs for me. I want to handle when the async process completes so that I need to update a field in db. Where do we get this handler or how do I achieve this? Because main thread would have already returned.

Posted a question previously on the same. Implement Async process for external service with callback to main Request - Spring But now I am making it more specific

1

1 Answers

0
votes

I don't think I understand your question completely, but may thenAcceptAsync be what you are looking for?

    cf.thenAcceptAsync(resultOfCompletableFuture -> {
        //update a field in db with resultOfCompletableFuture
    });