Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RMI Callback - Help Needed!

 
Emile Ghazzawi
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Emile Ghazzawi
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 284
Debian Firefox Browser Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Edward Harned
Ranch Hand
Posts: 291
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this tutorial:
http://java.sun.com/developer/onlineTraining/rmi/exercises/RMICallback/index.html
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic