Streaming data from Cache
Hi everyone,
I am trying to build an application based on real-time streaming data. A back-end program is continually writing to the Cache database, and then the data from the Cache database is retrieved through a REST API by a front-end program. The REST API is static -- it just gives the front-end all the data in the database at the time it was called. The problem is that every time the Cache database is updated, I need to send the newly arrived data to the front-end, but with the static API, there is no way I can, (I can keep sending requests to the REST API, but that would be a waste of resources since the front-end already has most of the data). I am just wondering if there's anyway I can solve this problem.
Best,
Trung
'
Comments
Hi,
without any REST (at that point) as you expect to hand action from front-end to back-end:
If your front-end is able to listen on a dedicated IP port then all you need is to send your data to the (negotiated?) IP:port.
Take a look to %Net.HttpRequest
http://docs.intersystems.com/latest/csp/documatic/%25CSP.Documatic.cls?…
From point of view of Caché your front-end acts then like a web-server receiving data.
Your reply from front-end signals to Caché that the front-end is ready for the next junk / or terminates the stream
There are several ways to do that.
- Add from/to arguments to your existing REST servise, so your client asks for a data within a specified time slice.
- Specifying no arguments yields all data
- Specifying only from yields data starting at from and till now
- Specifying both from and to yields only data acquired between from and to
- Use websockets.
Thanks everyone, I've decided on Websockets as a good solution. I'll try it out and let you know.