[jboss-user] [JBoss Remoting Development] - How to set timeout for method invocation?

Jacek DÄ…browski do-not-reply at jboss.com
Fri Mar 26 08:44:24 EDT 2010


Jacek DÄ…browski [http://community.jboss.org/people/jdabrowski] replied to the discussion

"How to set timeout for method invocation?"

To view the discussion, visit: http://community.jboss.org/message/534163#534163

--------------------------------------------------------------
I found some simple example which could be easier to test:

Hashtable<String, String> props = new Hashtable<String, String>();
props.put(InitialContext.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
props.put(InitialContext.PROVIDER_URL,"jnp://" + urlRemoteMachine);
props.put(InitialContext.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
props.put("jnp.timeout", "1000");
props.put("jnp.sotimeout", "1000");
InitialContext initialContext = new InitialContext(props);
MyBeanRemote remote = (MyBeanRemote) initialContext.lookup("MyBean/remote");
System.in.read();
System.out.println("Start");
System.out.println(remote.someMethod());
System.out.println("Stop");

When server is down lookup fails after jnp.timeout, but when I stop program on read() and then turn off remote server remote.someMethod() whaits a long time before returning with Exception:

Exception in thread "Main Thread" org.jboss.remoting.CannotConnectException: Can not get connection to server.  Problem establishing socket connection.
    at org.jboss.remoting.transport.socket.SocketClientInvoker.transport(SocketClientInvoker.java:268)
    at org.jboss.remoting.RemoteClientInvoker.invoke(RemoteClientInvoker.java:143)
    at org.jboss.remoting.Client.invoke(Client.java:525)
    at org.jboss.remoting.Client.invoke(Client.java:488)
    at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:55)
    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
    at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61)
    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
    at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:53)
    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
    at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:77)
    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
    at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:102)
    at $Proxy5.someMethod(Unknown Source)
    at myapp.Test.main(Test.java:104)
Caused by: java.net.ConnectException: Connection timed out
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
    at java.net.Socket.connect(Socket.java:519)
    at java.net.Socket.connect(Socket.java:469)
    at java.net.Socket.<init>(Socket.java:366)
    at java.net.Socket.<init>(Socket.java:180)
    at org.jboss.remoting.transport.socket.SocketClientInvoker.createSocket(SocketClientInvoker.java:526)
    at org.jboss.remoting.transport.socket.SocketClientInvoker.getConnection(SocketClientInvoker.java:472)
    at org.jboss.remoting.transport.socket.SocketClientInvoker.transport(SocketClientInvoker.java:264)
    ... 14 more

--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/534163#534163]

Start a new discussion in JBoss Remoting Development at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2051]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20100326/02232384/attachment.html 


More information about the jboss-user mailing list