I use weblogic example: http://groovy.codehaus.org/Groovy+and+JMX to connect jmx with groovy
Problem is that connection takes too long:
long time = System.currentTimeMillis();
println System.currentTimeMillis() - time;
def server = JMXConnectorFactory.connect(serviceURL, h).MBeanServerConnection
println System.currentTimeMillis() - time;
I have about 200 groovy script. Every script is doing something else but all need to connect to jmx. When I want to execute all it take about hour and more. Is there some options how to do it faster ?
so the answer is very simpler. I need to use this project: http://kobo.github.io/groovyserv/
then I just created class JmxSharedConection
with static method where I add connection and now it works much faster
I would take tim's suggestion and implement a shared connection as a [synchronized] singleton. So in effect, you establish the connection once and then each script uses it as needed. For some extra pizass, register a connection listener to your JMXConnection, and when connectivity is lost, start a reconnect loop, throwing exceptions to the calling scripts until you reconnect.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With