It's not a secret anymore!
The moose likes Java in General and the fly likes RMI Client-Server Applications Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "RMI Client-Server Applications" Watch "RMI Client-Server Applications" New topic
Author

RMI Client-Server Applications

Jeff Storey
Ranch Hand

Joined: Apr 07, 2007
Posts: 230
Hi. If I was creating a client-server application using RMI, I have a couple of questions. My main issue deals with how a server sends responses back to client requests. First, let's start with client to server messages though. My assumption is that the client would lookup the server via RMI and put a message on its queue to be processed (or something like that). However, when a server sends a message, it may need to send it to all clients (maybe a message that the server will be shutting down). What do you think would be the best approach for this?

When a client first connects to the server, the server can keep a reference to that client (by ID number maybe). But then, how does it know how to send the message back to the client? It can't simply lookup the client object via RMI and give the message that way (otherwise it would need to know how to access all the clients).

Maybe the client would poll the server for messages?

Any thoughts on this?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24061
    
  13

The client can have its own remote interface and implement its own servant object, and pass a reference to the server via a "registerCallback()" sort of method. Then when the server needs to tell the client something, it can use that callback. The client servant doesn't need to be registered in any name service, since the server never needs to look it up. It's a quite common design.

The only problem is that this won't necessarily work if the client is behind a firewall; the client would need to set up a SOCKS proxy for that, making it impractical for Internet deployment.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: RMI Client-Server Applications
 
Similar Threads
Servlet server communication problems
Chat application
RMI Client-Server Applications
What would be the best distributed method to use?
help with updating a JList