How to set request timeout for JMX Connector

扶醉桌前 提交于 2019-12-03 05:37:32

If you use default JMX protocol - the RMI - then the best option for the client side timeout is the global RMI connection timeout. Of course it will work only if you do not need to use RMI connections that have to be open forever.

Here is sample property for the timeouts (taken from Oracle RMI documentation: http://docs.oracle.com/javase/7/docs/technotes/guides/rmi/sunrmiproperties.html):

-Dsun.rmi.transport.tcp.responseTimeout=60000

I have tested it, it really works. In the oracle documentation there are also few other useful properties for client and server side of the communication.

u can try these codes to set the JMX connector timeout:

   JMXConnector connectWithTimeout(JMXServiceURL url, long timeout, TimeUnit unit) {
    ExecutorService executor = Executors.newSingleThreadExecutor();
       Future<JMXConnector> future = executor.submit(new Callable<JMXConnector>() {
            public JMXConnector call() {
                return JMXConnectorFactory.connect(url);
            }
              });
       return future.get(timeout, unit);
          }
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!