Saturday, March 1, 2008

timeout on JNDI lookup

for a jboss.remoting EJB client there are two ways of discovering the available servers on the net. one approach is to send multicast packages and wait for the servers to respond. this kind of auto-discovery only works if the servers are able to receive multicast packages from the clients which often is not the case.

the other approach is to provide a list of servers in the JNDI properties:,

all the servers in the list will be tried out sequentially. if one of the servers is not responding it may take a while until the client recognizes that and proceeds with the next server in the list. to avoid a long and not deterministic timeout behaviour additional JNDI properties can be provided:

this is possible because the remoting client uses a special implementation of the SocketFactory by default. The TimedSocketFactory tries to connect to the server and aborts after a given timeout period. the jnp.timeout defines the amount of time the factory will wait for a response on the initial connect. the jnp.sotimeout specifies the period of time the factory will block the read operation on the connected socket waiting for an answer.

No comments: