Problem
To reduce the throughput on the servlet container, how to asynchronously handle the request?
Solution
When a request comes in it is handled synchronously, which blocks the HTTP request handling thread. The response stays open and is available to be written to. This is useful when, for instance, a call takes some time to finish and instead of blocking threads this can be processed in the background and return a value to the user when finished.
Problem
Given a service, or multiple calls, how to collect the results from them and send the response to the client.
Solution
Use a ResponseBodyEmitter
(or its subclass SseEmitter
) to collect and send the response to the client.
Problem
How to use bidirectional communication from the client to the server over the web.
Solution
Use WebSockets to communicate from the client to the server and vice versa. WebSockets provide full duplex communication, unlike HTTP.
Problem
How to use STOMP (Simple/Streaming Text Oriented Message Protocol) over WebSockets to communicate with the server.
Solution
Configure the message broker and use @MessageMapping
annotated methods in an @Controller
annotated class to handle the messages.