aspose file tools*
The moose likes Distributed Java and the fly likes RMI Callback - Help Needed! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "RMI Callback - Help Needed!" Watch "RMI Callback - Help Needed!" New topic
Author

RMI Callback - Help Needed!

Emile Ghazzawi
Greenhorn

Joined: Dec 30, 2002
Posts: 28
I have created an application that uses RMI with a Client and a Server. They can both communicate effectively but i would like to implement RMI Callback so that the Server can pass back messages and invoke methods on the client.

I have looked at numerous RMI callback examples but they are often poorly explained or use long winded examples, all of which are going completely over my head.

My question is: Are there some simple steps or lines of code that can be added to add RMI Callback functionality to an exisiting RMI implementation?

Any help or examples would be hugely appreciated.

Thanks in advance!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42625
    
  65
RMI is a one-way mechanism - the client calls the server. If you want the server to be able to call the client, you'll need to set up the client as an RMI server as well.


Ping & DNS - my free Android networking tools app
Emile Ghazzawi
Greenhorn

Joined: Dec 30, 2002
Posts: 28
I understand the concept and logic behind RMI Callback i am just struggling to understand how i change my current RMI code to make it happen.

Could someone please explain the steps necessary to do so. I am a complete Java beginner way out of my depth here but it is something that i would really like to understand and get working!

Any help is much appreciated.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42625
    
  65
Well, if you have RMI working one way, just do the same the other way around to make it happen in the opposite direction. There is no way to set up an RMI connection to work both ways.
Oricio Ocle
Ranch Hand

Joined: Nov 30, 2004
Posts: 284

Hello Emily,
as Ulf Dittmer suggests, most common way to achieve this is exporting (in rmi sense) a listener object client side.
This lead to open a ServerSocket client side, with can be problematic in almost all network environments.
Other way is using long lived connections as i suggest in this post:
RMI client behind NAT. Callback implementation .

Recommended way in production environments is using a polling mecanishm.

Regards,
Oricio
[ July 29, 2007: Message edited by: Oricio Ocle ]

SCJP, OCMJD, OCMJEA
Edward Harned
Ranch Hand

Joined: Sep 19, 2005
Posts: 291

Try this tutorial:
http://java.sun.com/developer/onlineTraining/rmi/exercises/RMICallback/index.html


Ed's latest article: A Java Parallel Calamity http://coopsoft.com/ar/Calamity2Article.html
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: RMI Callback - Help Needed!