RMI Section Index | Page 6
Where can I find a detailed instructions for the steps to be followed while using RMI with applets?
You can find complete details for getting RMI to work with applets, along with example code at:
http://java.sun.com/j2se/1.3/docs/guide/rmi/getstart.doc.html
more
I have been implementing an RMI client/server system which needs to detect when clients are finished with their remote references. On Windows, the clients set the reference to null and call system.gc() which invokes the unreferenced method on the server. Under solaris however the unreferenced() method is not called (even if System.runFinalization() is called). Any ideas why?
The unrferenced() method is only called when ALL clients no longer hold a reference to the remote object or when the lease time expires,
(java.rmi.dgc.leaseValue.)
The Registries, (RMI/JN...more
How can I better handle threading in RMI? How could I have a thread pool that RMI uses to service clients rather than create a new thread each time? Is this within the power of the developer, or does it need to be part of the underlying RMI implementation?
Technically, you already have a pool of threads. If your Server handles ten
concurrent requests, then there are ten RMI Connection Threads processing these requests.
As each request f...more
How can I uniquely identify clients in RMI?
First -- there is always CallBack. By passing the Server the Client "RemoteObject", the Server knows the ID of the Client.
Secondly -- Although there is an rmi Server method, getClientH...more
How do I read/write a file from the implementation class of the RMI Server so that it does not give the AccessControlException?
This is the security feature of Java. Use a policy file and specify the location on the command line for the Server: -Djava.security.policy=file:/path_to_policy_file
See the security featur...more
Is there a simple way to find out if the activation system (i.e. rmid) is currently running?
Start first with (default rmid port at 1098):
ActivationSystem system=(ActivationSystem)Naming.lookup("//:1098/java.rmi.activation.ActivationSystem");
If (system==null), the activatio...more
What is difference between bind and rebind?
bind(String name, Object obj) will throw an AlreadyBoundException if there's already an object bound to that name within the rmiregistry. If there was no match, the
object will be bound to the ...more
How can I scale an RMI server? For example, how can I spread workload of RMI server between several server hosts?
What you are looking for is called Load Balancing. Most developers use an
intermediate RMI Server, a Router.
The Router contains the logic to determine which Server should process the reque...more
If the RMI server broadcasts some data to all clients via callbacks, and one of the clients is in deadlock, how can I timeout the method invocation? Is there a way to "post-and-forget" method invocation from server to the client?
There is no method invocation timeout that we know about. We use application
threads to process our Client's requests.
You can start a new thread for each Client call back. If the thr...more
How can I increase the maximum number of requests that an RMI server can handle simultaneously. I am getting connection refused error after 25 request are made simultaneously from 25 threads in a client.
Without knowing more of the details, you may be running into a temporary condition,
(like a packet storm), where the receiver is overloaded. We use a retry loop for
connection errors.
// try to c...more
How can I run a single JVM for different classes that are activated by different activation classes? For example, by default, if I create activatable two class ActClass1 and ActClass2 and run them I get two JVMs. Is it possible to run both classes in one JVM?
I believe this is controlled by the ActivationGroup. When you register the class you are probably doing something like:
Properties props = new Properties();
props.put("java.security.polic...more
How can I have multiple clients remotely access multiple instances of a particular remote server? Apparently, RMI only allows for Point-to-Point communications between a client and a Remote server. I have a need for multiple instances of that Remote server to handle high volumes of client requests. Is there a way to utilize the RMI frameworks to accomplish this task?
How can I have multiple clients remotely access multiple instances of a particular remote server? Apparently, RMI only allows for Point-to-Point communications between a client and a Remote server...more
In the RMI CallBack Mechanism the reference of the client is sent to the server along with the request. Firstly is there any way to store the reference of the client in the database which can be retrived later to send the response to that specific client. Secondly, how can the server restrict the request coming from a specific client, i.e how to get the ip address of the client from the reference?
Firstly:
java.rmi.server.RemoteObject implements Serializable so you can serialize the reference and save it to a byte array or use toString(), etc. We took the below quote rrom the RMI-IIOP Progr...more
How can I programmatically stop a RMI server?
RMI Servers start a thread that never ends. This is so that the Server is persistent
until manually shut down.
However, you can provide a remote method, shutDown(), for the Remote Server.
Thi...more
Are there any tips or rules for increasing performance of RMI calls?
So far I discovered only one rule of thumb: avoid passing objects as parameters or return values - primitive types serialize much faster than objects because Java objects are so flat. The only obj...more