Periodic data updates to Web Clients

Using Java EE7 - Web Sockets

We have several ways to publish periodic data updates from server to client. Data updates like Stock price update, or Account available balance, or Next auction time, etc. might be decided by business logic on server and might be need to propagated to Web clients to display. If server application not itself generates such data, it might be receiving from some other source, and it needs to pass to web clients, because Web clients might now know when data is available.

One way is to pass the Event to client and one way is to provide update on Web Socket.

A sample design using Web Socket can be like -

Below is the sample code, which is there on Oracle site.
WebSocketEndpoint is a java class whose code is very simple like below -

And JavaScript code on Web Client is like below -


Popular Posts