Issue
I have an Angular application, where once a person is checked in to the room, they are added to a list and their data is sent to a third party system. Now the sending of the data to the third party system happens every 3 minutes in batches via the backend. Only when the data is transferred successfully is the person completely registered and has a green check mark next to his name on the list. Otherwise though the person is checked in, he is still marked as yellow.
So, each time a person is checked in, the backend is notified and the data is persisted. Then the transfer happens to another system through a batch processing every three minutes.
How to notify angular app that the transfer was successful, so that all persons transferred have the green check mark next to their name on the list?
I was thinking that each time a person gets added the request is sent to backend and the backend will respond only after the batch job completes and the transfer is successful. So that would be a delayed http response of 3 minutes per request. I guess there is definitely a better way to do this!
Solution
There are two main ways you can go about sending data from your backend to your frontend:
Set up a socket connection and emit an event from the server when you want the client to be notified (read this)
Do polling on server (can be a little heavy on the server traffic depending of your overall architecture, number of clients, etc) (read this)
Polling is generally easier to do, but is not real time and you have to consider the potential load on your server. Sockets are real time, but you have to adjust your architecture to fit them in.
Answered By - Haris Bouchlis
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.