java - RMI: thread waiting on server side -


i have following code:

public interface rmiserver extends remote{    public string getmessage()throws remoteexception; }  public class defaultrmiserver implements rmiserver{   private linkedblockingqueue<string> queue;    @override   public string getmessage()throws remoteexception{     return queue.take();   }   ... } 

when rmi client calls getmessage() method clear there can 2 situations:

  1. there message in queue , method returns
  2. there no message in queue , thread waiting

what happen in second case rmi call? how long client wait?

sun rmi client connection's timout being controlled property sun.rmi.transport.tcp.responsetimeout, default set no timeout (=waits forever).

sun.rmi.transport.tcp.responsetimeout (1.4 , later):

the value of property represents length of time (in milliseconds) client-side java rmi runtime use socket read timeout on established jrmp connection when reading response data remote method invocation. therefore, property can used impose timeout on waiting results of remote invocations; if timeout expires, associated invocation fail java.rmi.remoteexception. setting property should done due consideration, however, because places upper bound on allowed duration of successful outgoing remote invocation. maximum value integer.max_value, , value of 0 indicates infinite timeout. default value 0 (no timeout).

for list of , other parameters can used control rmi connections see sun.rmi properties


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -