• Post Reply Bookmark Topic Watch Topic
  • New Topic

RMI Fundamentals  RSS feed

 
Jason Kingsley
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Is my understanding correct (am looking at moving a C# Remoting project to Java)?
Objects that are exported (ie reachable from another process space) and that usually subclass UnicastRemoteObject listen on their own server socket?
So for example, we have a well named object "Foo" that is bound in the naming registry (say 1099) so that when an RMI client looks it up it can discover Foo fine. Foo, creates a remote object:
public class MyRemote extends UnicastRemoteObject implements MyRemoteInterface
{
public void doThisMethod() throws RemoteException
{
//
// do work...
//
}
}
that it returns to the client, who has the appropriate stubs. Now, that instance of MyRemote is now listening on an arbitrary port for incoming connections like a mini-server, and whats more, is in its own thread.
Any incoming connections themselves will spawn their own thread to service the remote call.
This has ramifications in that this object, on an arbitrary server port is unreachabe if on the inside of a firewall and whats more, any remoted object is consuming resources with threads and server socket.
With this in mind, RMI doesn't particularly scale well or even cater even for groups of remoted objects providing services to a few dozen clients and seems more designed for heres a small number of global objects that facade for some logic.
Cheers
 
Chris Shepherd
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you've basicaly got it right. I don't know if remote calls to the server methods create new threads.
 
Jason Kingsley
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
Thanks for the reply, I wrote some test code and every new'd remoted object spawned in its own thread with a server socket and blocked waiting on accepts from client connections which would intern be run in their own threads on the accept.
So for n exported objects with m concurrent calls it looks like you get n+m threads.
Cheers
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!