Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

[B&S] RMI client disconnect

 
Jaco Bekker
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All

Background: I have a DataRemote class which are made available on the RMI registry for clients to refer to. A client uses which returns an int clientId and refers to a Data object created for each client, in DataRemote within a HashMap. So a client my invoke a data related method on dataRemote with its clientId to access the data, eg.



A client disconnects from the server by which frees that client's resources.

My question is how to determine when a client has disconnected prematurely, that is without using removeClient, so that DataRemote can free that clients resources? If this isn't done, it could become a ugly memory leak.

Thanx

Jaco Bekker

SCJP 1.4
 
Jeroen T Wenting
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yup, that's the problem with RMI. There's no way to detect removal of any single client referencing any single Remote object. You can only (through Unreferenced) detect when there are no more clients at all.
Of course you could rewrite the whole thing so each client has its own DataRemote, and let DataRemote in its unreference notify the server of the disconnection.
 
Oricio Ocle
Ranch Hand
Posts: 284
Debian Firefox Browser Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jaco Bekker wrote:
... refers to a Data object created for each client ...

Jeroen T Wenting wrote:
... rewrite the whole thing so each client has its own DataRemote

In that sceneario rewriting is minimal.

Search information about 'connection factory' in the forum, sure you'll find it useful.

Regards
[ June 12, 2006: Message edited by: Oricio Ocle ]
 
Oricio Ocle
Ranch Hand
Posts: 284
Debian Firefox Browser Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The more i read it the more i like it:
Andrew's connection factory example
IMO the finest RMI solution in a non-cookie-based scenario

Regards
[ June 12, 2006: Message edited by: Oricio Ocle ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic