Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RMI multithreading

 
K. Tsang
Bartender
Posts: 3521
16
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, I have a question. Is multithreading build into RMI already? Do I need to cater for this specifically on my RMI server? I asked this because once I get my RMI server running, I don't seem to get any output to the console when clients connect like printing "there are x clients connected". Thanks
 
Alex Belisle Turcot
Ranch Hand
Posts: 516
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
K. Tsang wrote:Hi all, I have a question. Is multithreading build into RMI already? Do I need to cater for this specifically on my RMI server? I asked this because once I get my RMI server running, I don't seem to get any output to the console when clients connect like printing "there are x clients connected". Thanks

Hi,

I'm not sure I understand entirely your question.. Let me try to go trough a sequential scenario:

- You start your RMI Registry;
- You start your server;
- You bind an Object from your server into the Registry (this will be the Remote object);
- You start several clients;
- Several clients can get a reference to your remote object from the RMI Registry;
- Multiple threads will be started/used by the RMI runtime upon concurrent call of a method on the remote object;
- It is up to RMI to reuse a Thread or create a new one when a request is made (and ultimately destroy it).

Does this helps ?

Alex
 
Fernando Franzini
Ranch Hand
Posts: 489
2
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Alex....Let me asked somenthing about RMI....there will we only one instance object bind inside RMI control and many remote proxy references ? .....like servlet inside servlet container ?
 
K. Tsang
Bartender
Posts: 3521
16
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Alex, from your description and the look of things, RMI is multithreaded already.

The thing I hope to do for my RMI server is to display messages as clients connect.




 
Alex Belisle Turcot
Ranch Hand
Posts: 516
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
K. Tsang wrote:thanks Alex, from your description and the look of things, RMI is multithreaded already.

The thing I hope to do for my RMI server is to display messages as clients connect.







I'm not sure if your server can tell if a client gets a reference to your object..
I guess you should add a method on your remote class and have each client calling it..

something like:


Regards,
Alex
 
Alex Belisle Turcot
Ranch Hand
Posts: 516
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fernando Franzini wrote:Hi Alex....Let me asked somenthing about RMI....there will we only one instance object bind inside RMI control and many remote proxy references ? .....like servlet inside servlet container ?


That's exactly my understanding, the server instantiate an object and makes it available through the RMI Registry. Sor sure, any client requesting a reference will get the same one.

I know what you mean with the servlet example, but in my opinion the concept is not the same. With Servlet, the clients don't really hold a reference to it and there *could* be different servlet handling requests from different clients based on the webapp configuration.. Anyway, I don't want to argue on semantic, I think you get it..

A similar concept (as RMI) would be EJB Stateful Session bean..

Regards,
Alex
 
Fernando Franzini
Ranch Hand
Posts: 489
2
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes Alex...I agree with you...Like stateful EJB !!.
see yah.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic