How can the data requested per second under N threads ensure the consistency of data per second?

the existing requirements are as follows:
N threads retrieve similar data every second from various interfaces on different platforms, and do a cleaning and sorting operation on the data, and then send the data to the front end for display. The final effect is to display the data in real time.
the existing problems are as follows:
I set the counter and print the program results run by the thread per second. It is found that the data fetching action per second may fail, and the response may fail or the response delay may be delayed. The final result is > some of the existing N data may be within the current 1 second and some within the previous time. If the data is directly transmitted to the front end, then the data actually does not meet the requirements.
preliminary idea:
1. Send the data fetched by the thread per second to the front end using websocket, and then display it separately?
2. Set up a status field for the data you get every second, and check it according to the status field.
java has been developing for a year. It"s a bit confusing to come into contact with this problem for the first time, and ask the old bird to teach

.
Mar.30,2021

  1. on the data processing side, instead of processing the data as soon as it is received, it adopts a timing processing method (for example, data processing is performed every 5 seconds, the definition of timer interval is mainly considered, in most cases, the network delay)
  2. the sender or the generator sets a timestamp for the emitted data (the accuracy of the timestamp is determined by the actual situation. If you say so, set it to seconds)
  3. data processing side, only data with the same timestamp is processed each time
Menu