I am writing a small desktop application which is about showing notifications to the client who is using this application.so my application should get notifications from a server where all the notifications are stored.so if there are 100 clients using this app and if I add some notifications to server how can I send these data to 100 clients...please give me some idea what APIs or which technology I can use to get this functionality implemented.this application is a desktop application
-
1you can use JMS broadcast – prsutar Nov 27 '14 at 17:13
-
There are a couple of patterns that might help you, `Observer` and `publish–subscribe`. You should have a look at those. As suggested above, JMS is an option but you might not need the complexity in your application – Desorder Nov 27 '14 at 21:45
-
@Desorder : Can you please elaborate on publish-subscribe method – Prajyod Kumar Nov 29 '14 at 04:23
3 Answers
There are some possibilities:
1. Via Sockets, ServerSocket/Socket/Multicast
Push-Notification: Open a listening socket on every client and open a connection from server to send a notification from server to client.
Pull-Notification: Open a listening socket on the server and open e.g. every 10 seconds or so a connection from the clients to the server to look for new notifications on the server.
Multicast: Send the same message to multiple clients with one API call.
2. JDBC/JPA: Transfer messages over the database, if you have one.
3. JMS: Use a message topic
...
The best method depends on your needs.

- 603
- 5
- 15

- 1,850
- 1
- 11
- 16
Its simple ...
1) Make Arraylist of socket that has socket of all clients. // i.e when new client connected then add its socket into th ArrayList.
2) When ever there is any update just iterate through the ArralyList and send notification to all the connected clients.

- 2,572
- 6
- 41
- 77
There are two (maybe more but I know those two. :) ) patterns to deal with those types of scenarios. Observer and publish-subscriber
They are very similar with the difference that for the Observer pattern, the "standard" implementation might create memory leaks while in a publish-subscriber scenario, neither the publish or subscriber knows about each other.
Have a look a the links below that might give you a better idea.
http://en.wikipedia.org/wiki/Observer_pattern http://www.oodesign.com/observer-pattern.html
http://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern http://www.eaipatterns.com/PublishSubscribeChannel.html

- 1,549
- 12
- 16