I have implemented RMI in my UrlyBird project, and when a client connects they get a list of Booking objects and these are displayed in the GUI. (similar to the implementation used in the SCJD Exam book). These booking objects are a COPY of the booking objects on the server (The Booking objects implement Serializable)
What I would like to do though, is when a client updates a record is for the server to send out an Event object (or something similar) to all the clients connected, telling them that Record number nn has been updated - get a fresh copy of this record and redisplay on the GUI. Also when a Booking is locked, for the record on screen to be greyed out (for example)
(The implementation in the SCJD book waits for each client to do something, and then goes to the server to get a list of ALL records).
I've looked through the posts on this forum, but could'nt find anything relating to my query.
Can anyone help me out?
Regards Phil [ June 23, 2004: Message edited by: Phil Harron ]
What you are talking about would require a great deal of bandwidth and is also computationally intensive. Every time a user updates a record, the server has to connect to every client and send them information over the network. Every client will then make a new request for a fresh view over the network and then the server will again have to communicate with every client over the network to send them the updated information. Imagine 200 clients! Not only does that require a lot of bandwidth, but it also requires a lot of processing to be done on the server. Also, if the client is constantly being harrassed to refresh its records, it will be less responsive to the user. Finally, say there are 10,000 records in the database. Each client is probably only concerned with at most a few of them and should not be bothered with updates to irrelevant records.
For these reasons, I think that you should not follow through with this update notification idea. Just a suggestion
Joined: Sep 25, 2003
If you really wanted to notify all clients of certain events, you could use a MulticastSocket.
Joined: Jun 21, 2002
I agree with your comments Anthony - much appreciated. One point though - surely this is the way real world applications might work? I know they would have more processing power and bandwidth, but how much bandwidth would it take to send an event object down the wire (only holding the recNo of the booking to refresh) to the client. What about the example in the SCJD book, if it had 200 clients who were all doing an update/refresh constantly . I might just try to do this anyway and see how it copes/what happens in both applications.
Do you think then its enough to leave the Server/Gui as is then and when the Client does something it does a refresh?
Thanks again Phil
Joined: Sep 25, 2003
Is there any need to perform a refresh if you do not know for sure that the client's data is stale? Is there any need to refresh if the client is not modifying a record?
I believe that in the real world it is uncommon for servers to notify remote clients of events because of bandwidth and scalability issues.