This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "RMI Callback - Help Needed!" Watch "RMI Callback - Help Needed!" New topic

RMI Callback - Help Needed!

Emile Ghazzawi

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

Joined: Mar 22, 2005
Posts: 41155
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

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

Joined: Mar 22, 2005
Posts: 41155
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.

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

Edward Harned
Ranch Hand

Joined: Sep 19, 2005
Posts: 291

Try this tutorial:

Ed's latest article: A Java Parallel Calamity
I agree. Here's the link:
subject: RMI Callback - Help Needed!
Similar Threads
RMI Callback using socket pools
RMI client callback stub
How to let RMI implement broadcast
Callback Pattern with different Arguments?
RMI Server problem