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 asyncfunction 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".
You could use websockets. There's a simple example here that uses STOMP to pass messages back and forth.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With