Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set request timeout for JMX Connector

Tags:

java

jmx

I'm trying to set request timeout for JMX Connector but seems like it doesn't work.

env.put("jmx.remote.x.request.waiting.timeout", new Long(30000));

But since it didn't work, i googled to see the reason and found out that in standard JMX remote api doesn't support the above environment variable.

Is there any other way to set the request time-out?

like image 748
sasankad Avatar asked Oct 08 '12 23:10

sasankad


People also ask

Is JMX enabled by default?

The SpringSource dm Server always starts with JMX access enabled, allowing you to use a management tool such as JConsole to attach to the dm Server instance. By default both local access and remote access over SSL with username and password authentication are provided.

Does JMX use TCP or UDP?

The JMX Messaging Protocol (JMXMP) connector is a configuration of the generic connector where the transport protocol is based on TCP and the object wrapping is native Java serialization. Security is more advanced than for the RMI connector.

What is JMX config?

JMX runtime configuration is unique because it provides you with some control over how much configuration is displayed. The JMX client for the agent can connect to several different types of application servers, but it is usually not necessary to support all of those types of application servers in any one agent.


2 Answers

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.

like image 89
bartosz.r Avatar answered Oct 03 '22 05:10

bartosz.r


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);
          }
like image 38
Deepak Sharma Avatar answered Oct 03 '22 06:10

Deepak Sharma