How is the status returned by the java asynchronous callback function notified to the foreground?

such as the question, with asynchronous functions also deal with data, but how to feedback to the foreground? It would be nice to give some ideas

Feb.26,2021

personally, I think the simplest way is to use short polling:

A1sB

can only poll one more interface, and the server cannot send a http request directly to the client.


WebSockets can make a web page dynamic and interactive. However in many cases a combination of Ajax and HTTP streaming and/or long polling could provide a simple and effective solution.

For example news, mail, and social feeds need to update dynamically but it may be perfectly okay to do so every few minutes. Collaboration, games, and financial apps on the other hand need to be much closer to real time.

Latency alone is not a deciding factor. If the volume of messages is relatively low (e.g. monitoring network failures) HTTP streaming or polling may provide an effective solution. It is the combination of low latency, high frequency and high volume that make the best case for the use WebSocket.

read the springboot websocket document . When to use polling and when to use websocket is very clear. I'd better use polling obediently

.

polling is also possible, or a WebSocket connection is established between the foreground and the backend. After the data is processed, the server pushes feedback directly to the client.

Menu