• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

regarding RMI architecture

 
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!

I want to implement a project which will be on the basis of RMI.
I have one server and a couple of clients. When one client sends a screen to a server - server forwards it to other client.

I think that both client and server have to register their services in rmiregistry.
1). client invokes server's method to send a screen
2). server invokes client's method to forward a screen

Is it a good idea?

Thanks!
 
Bartender
Posts: 1210
25
Android Python PHP C++ Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Didn't understand why all the clients need to register in rmiregistry. Each client can implement a client interface (which should also be remote) and pass a reference to that while registering with server. Server uses the received reference to communicate with client.
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, so all of the clients implement Client remote interface and server implements Server remote interface.
During client creation reference is passed to Server.
Is it good?
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have written some code. Please, analyze that:

RemoteClient


Client


RemoteServer


Server


Please, notice that I do not use ClientRemote interface - I do not register it in rmiregistry.
I just pass a client's reference to Server and then Server invokes methods on that object. I tried it on localmachine and it works.
What about distributed machines? Will that work? I do not think so.

Please give me an answer.
 
Karthik Shiraly
Bartender
Posts: 1210
25
Android Python PHP C++ Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Sorry, am seeing this only now since I didn't get an email alert.

Yes, it works even in distributed case - I know because I've them working. Why do you feel it won't work?
Registering with naming registry is simply to give a label to a java reference so that other objects can get it. In the above code, RemoteClient reference is given directly to server, so it is being used, but just not registered.

Cheers
Karthik
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Got it! Thanks.
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry to barge in on this thread - haven't really used RMI - does RMI have a default port or how is that allocated in this particular code?
 
Karthik Shiraly
Bartender
Posts: 1210
25
Android Python PHP C++ Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By default, RMI naming registry is reachable on port 1099. In this code, the line

does not specify a port, so it defaults to 1099.

But that's not the only port in picture. Once lookup is done, client and server setup a TCP connection over random ports, unless server specifies specific port on which it'll communicate. This code is not doing it, but it can be done in the RemoteServer constructor as:

 
Stephan King
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks
reply
    Bookmark Topic Watch Topic
  • New Topic