I think the “best practice” here will depend on the number of desktop clients you expect to serve. If there is only one desktop to be notified, then a survey may well be a great approach - yes, a poll is a lot more overhead than an event-based notification, but it will certainly be the easiest solution to implement.
If the overhead of the survey is really unacceptable, I see two main alternatives:
- Maintain a persistent connection between the desktop and the web server (maybe a comet web request or a raw socket web connection)
- Open the service from the desktop application and register the service address on the web server. Thus, the web server can access the desktop as needed.
Be warned though - both alternatives are full of interception. A few highlights:
- Keeping an open connection can be tricky because you want your web servers to be a hot swap.
- Calling an external service (such as the desktop) from a web server is dangerous because this request may hang. You want to move this notification to a separate stream so as not to bind the web server.
To mitigate some of the problems, you can separate the untrusted desktop from the web server by introducing an interim notification server - the web server can post the update somewhere, and the desktop can poll / connect / register there to be notified. To avoid wheel reuse here, this may include some MessageQueue system ... This, of course, adds to the complexity of having to support a new middleman.
Again, all of these approaches are probably quite complicated, so I would say that the survey is probably the best choice.
source share