Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

rmi both ways

 
bertrand moulard
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm fairly new to RMI and I'm writting test code to see how things work. I wrote a server that registers itself and a client that connects the server and call it's methods. The thing I don't understand is how to get the server to call client methods. Say something happens on the server and it wants to notify all the connected client without having them asking anything? Is there a simple way to do that? (I've got that annoying feeling that I'm missing something really obvious...)

Thanks (and sorry if the question is stupid)
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll find more information on this topic using the phrase "RMI callback".

Basically you make the client a "server" also (meaning a class somewhere on the client has to implement Remote), and send a reference to it (the stub of the client side Remote) to the server, who saves it in a list of clients. Then, when the server needs to notify the clients, it uses the saved stub to "call-back" some method on the client.
 
bertrand moulard
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for that, it's been helpful!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic