Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Running Jolokia JVM Agent With Mule Standalone Runtime

DZone's Guide to

Running Jolokia JVM Agent With Mule Standalone Runtime

Learn to how to start the Jolokia JVM Agent for Java application monitoring with Mule runtime and enable HTTPS and basic authentication.

· Integration Zone
Free Resource

Modernize your application architectures with microservices and APIs with best practices from this free virtual summit series. Brought to you in partnership with CA Technologies.

Jolokia is a great way to monitor JVM applications and provide easy access to all the JMX goodies using simple JSON over HTTP. I would say that it has almost become the de facto standard when it comes to monitoring and managing Java applications.

While Jolokia does provide a specialized Mule agent, it does not allow us to expose the Jolokia interface over HTTPS (or enable TLS Client Authentication). On the other hand, this is supported by the Jolokia JVM Agent, and it also works great with the Mule Server Runtime. In this blog post, I do a step by step instruction on how to start the Jolokia JVM Agent with Mule runtime and enable HTTPS and basic authentication. 

  1. Create /opt/jolokia/

  2.  Download and copy the Jolokia JVM agent jar (in my case, jolokia-jvm-1.3.7-agent.jar) into /opt/jolokia.

  3.  Copy your keystore into /opt/jolokia (skip this step if you do not plan to use HTTPS to access Jolokia).

  4. Create a Jolokia properties file in /opt/jolokia. For a complete set of configuration options, see the Jolokia reference manual.

    port=8774
    host=0.0.0.0
    user=user
    password=password
    sslProtocol=TLSv1.2
    protocol=https
    keystore=/opt/jolokia/jolokia.jks
    keystorePassword=password
  5. In your Mule config, add the following additional Java argument. As usual, you need to change the <n> to be a consecutive number (based on the number of additional properties).
    wrapper.java.additional.<n>=-javaagent:"/opt/jolokia/jolokia-jvm-1.3.7-agent.jar=config=/opt/jolokia/jolokia.properties"
    wrapper.java.additional.<n>.stripquotes=TRUE
  6. Start the Mule runtime.

  7. Test by using curl.

  8. user @devws: ~$ curl - k https: //user:password@localhost:8774/jolokia
     {
      "request": {
       "type": "version"
      },
      "value": {
       "agent": "1.3.7",
       "protocol": "7.2",
       "config": {
        "maxDepth": "15",
        "discoveryEnabled": "true",
        "maxCollectionSize": "0",
        "password": "password",
        "agentId": "10.0.2.15-6850-4f023edb-jvm",
        "debug": "false",
        "agentType": "jvm",
        "historyMaxEntries": "10",
        "agentContext": "\/jolokia",
        "maxObjects": "0",
        "user": "ipf",
        "debugMaxEntries": "100"
       },
       "info": {}
      },
      "timestamp": 1506498074,
      "status": 200
     }
    user @devws: ~$

The Integration Zone is proudly sponsored by CA Technologies. Learn from expert microservices and API presentations at the Modernizing Application Architectures Virtual Summit Series.

Topics:
mule ,jolokia ,managament ,integration ,java ,jvm

Published at DZone with permission of Pontus Ullgren. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}