Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to notify java desktop clients about changes from server?

I would like to develop a desktop application with Java (I've got very basic knowledge of Java). It'll run on the client's computer and will pull information from the server hosted in the internet. I can set a schedule task to connect to the server every 2minutes and check for any update/changes but I don't think it's a very good idea. Is there any way to let the clients know about the changes? For example, when every there would a change server will send a notification to the clients to update? The server might a different technology e.g. Java

any help would be greatly appreciated, thanks again!

like image 456
Mahbub Avatar asked Sep 08 '10 21:09

Mahbub


2 Answers

Pushing to clients is always going to be hard - largely because of firewalls. Making the client pull from the server (with HTTP) is much more likely to work in most situations.

Now, you're currently polling every two minutes. That may be appropriate - or it may be better to do it much more rarely (once a day, say) depending on what you're updating. If it's updates to the client software, rare updates are fine. If it's updates to a chat conversation, even two minutes is far too long - in which case you should look into comet / long polling as a technique. (There are various technologies for implementing long polling; you don't have to use anything specific - that's why I described it as a technique rather than anything else.)

like image 186
Jon Skeet Avatar answered Nov 08 '22 07:11

Jon Skeet


You can use JMS to send messages from your server to your applications if you use a Java Server.

Or you could use a Comet application to push messages to the clients via HTTP.

A third way would be to create your own push system where your clients connect to the server to give some informations on how to be contacted, and with the Observer/Observable pattern you notify every client at each modification.


Resources :

  • Oracle.com - JMS
  • Wikipedia - Comet
  • Wikipedia - Publish/Suscribe
like image 23
Colin Hebert Avatar answered Nov 08 '22 08:11

Colin Hebert