Remote Method Invocation (RMI) - RMI multiple servers

hello.

i want to have 2 servers each one on a separate machine. When my client does lookup i'd like it to lookup for the 2 servers and interact with the first one it founds.

for now, both my client and server are on the same machine. i use

EmpInt e = (EmpInt)Naming.lookup("//""localhost""/EmpInt");

i want my client to lookup for a server and set a timeout if connection takes too long, then tries to connect to the other server. any tutorial would help

thank you

regards,

tally

[537 byte] By [vital30a] at [2007-11-26 23:27:25]
# 1

You can simply spawn two threads, each trying to connect to a different server and then discard the object that is returned last. It requires to write some coordination code, but it's not that complicated.

You can also read about the timeout values at:

http://java.sun.com/j2se/1.5.0/docs/guide/rmi/sunrmiproperties.html#connectionTimeout

genadya at 2007-7-10 14:36:14 > top of Java-index,Core,Core APIs...