Reputation: 785
If I have an endpoint, that when hit calls a function that has a CompleteabeFuture.runAsync()
call, how can I send this data back to the front end.
Here is an example of async
function similar to mine (just simpler):
CompletableFuture.runAsync(() -> {
int count = 0;
if(test.getNumberComplete() > count){
count = test.getNumberComplete();
logger.info("{}/{} complete so far", count, test.getNumberComplete());
}
}
Basically, this is running in the background after the Controller has already returned ResponseEntity
. So my question is, how can I return the data that is being logged in logger.info()
to my front-end. Is this possible at all since the Controller has already returned? My end goal is to show these results in the top corner of the website's screen, something like "1/3 complete so far".
Upvotes: 3
Views: 1363