Reactive Spring, CompletableFuture doubts

Viewed 67

I have a spring boot application where there is a rest controller. It gets invoked from angular and immediately responds with a message background work started.

The controller has also launched a long running service method decorated with @Asynch which completes after 10 minutes. When it completes the service it causes a websocket push to the front end via a topic expected by the front end.

This causes the front end to know that the background processing is done and it enables a new link that the user can now click.

This is loosely based on https://spring.io/guides/gs/messaging-stomp-websocket/.

Some Questions:

  • Can this objective also be achieved using reactive programming or CompletableFuture without websocket usage as indicated above?

  • Does it make sense for a Controller to use completableFuture.get() or .join() and thereby wait for the asynchronous service to finish. Is that also not blocking?

  • Can reactive streams be used for this. Can we instead return a list of two elements as a stream where first row is the message about "background work started" and second message is "background work done"?

  • Does this make sense? Is there any such non blocking example ?

0 Answers
Related