Question

I'm supposed to implement a web application where the user log's in and by that registers for some sort of events (in this case, alarms). When an alarm happens, the server needs to push the alarm to all of the clients.

At the moment I'm using

  • GWT on the Client side
  • Jetty on the Server side

Is implementing the server push by using Jetty Continuations a good idea? My requirements are:

  • the number of clients will be quite small (<20) but could increase in the future
  • alarms must not get lost (i.e. if the client will be down, it must not miss any alarms)
  • if a client goes down, other clients need to be informed about it (or at least the admin should receive some sort of notification, e.g. by Mail).
Was it helpful?

Solution

The main reason for using Comet (e.g. Jetty Continuations) is, that it allows to reduce the polling frequency. In other words: You can achieve the same thing without Comet, by using frequent polling from the client side. Which alternative to choose depends on the characteristics of your application - depending on that, each alternative can be more or less efficent than the other!

In your case, since you need notifications when a client goes down, it makes sense to use frequent polling. Comet (long polling) is not suited very well for this task: Because of its priciple, it can take a long time until a client sends a new request. And receiving a new request is the only way a server can know that a client is still alive (remember, that a web server - no matter if Comet or not - can never send a request to the client).

OTHER TIPS

Your requirement states that alarms must not get lost, implies a more complicated solution than long polling or frequent polling.

Your client should send an acknowledgement message to the server, because your user could close the application just after the alarm message arrived, he/she can loss that alarm. Also, your user should click an alarm message to acknowledge the server . You can put a time limit to acknowledge , if the client does not send an ack message , then you can assume that alarm has been lost..

Long polling with acknowledgment algortihm would be my choices to solve your problem..

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top