• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is my RMI understanding true ?

 
steve mcdonald
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please validate the following points and my understanding of RMI

1. An RMI Server controls the threads, may perform pooling of worker threads.

2. It is guranteed that when a remote method call is executed, a unique thread is assigned and serves the entire method execution.
also means that

3. Thread.currentThread() object is unique per request and is safe to use and perform any code with in the method code.
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12007
215
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Steve,

I don't think point 2 is guaranteed - the specification does not state what must happen here. However it would be unusual for an RMI implementation to change the thread in the middle of executing an individual method - such an RMI implementation would have to modify the standard JVM infrastructure. While there may be a few circumstances where this could be advantageous, the extra work would be disadvantagous for standard usage.

So I think you can go with an assumption that point 3 will work (at least in the Sun reference RMI implementation which we have to use).

Just a quick note to make sure that others don't misinterperet point 3 though - this is only potentially true within one RMI call. One client calling two remote methods one after the other may find that the two methods execute in different threads. Furthermore a separate client may also use the same thread used by the first client for executing it's remote method (although no two clients can use the same thread simultaneously).

Regards, Andrew
 
steve mcdonald
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Andrew, well i implemented with Thread.currentThread() implementation and while i started writing the business Services, i realized that this assignment is also to test how we implement session management from the clients as well.

So i started off with a different route in my assignment is to use AtomicLong class to gen unique client id's by the DB Server upon initial handshake from the client and keep track from there.

After that the client will pass clientid that it got for every request, under the covers and not by passing as an argument on every business service call.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic