I am new in Java Spring microservice architecture. I have a sensor that sends every second a value: for example a number=100, number=102, number=104, ..... during a 30 min.
I have simple code that takes data from sensor and returns a dynamic variable.
I can see it like this: log.info("Data from sensor: "+number);
And as a result we can see the output in the console:
Data from sensor: 100 Data from sensor: 102 Data from sensor: 104 .....
The question is What is a better way to show this variable using microservice architecture? What to write in Controller.class under @GETMAPPING ("/sampledata") For example, when we run a simple microservice, it will show us a static data. Browser: localhost:1234/api/sampledata . Browser will return us a final result "Hello, World!" or something like "{Client=Josh, age=20, Surname=Siemens}". But how to make the microservice, that will never stop and update the result? For example, once opened Browser: localhost:1234/api/sampledata and on display we see the dynamic results:
Data from sensor: 100 like Temperature: 36 C
in 1-2 seconds the value will change.
Data from sensor : 102 like Temperature: 36,2 C
Any ideas how is it possible to do it? Maybe not only spring, maybe javascript or something like that??
Aucun commentaire:
Enregistrer un commentaire