Using Jolokia and Hawtio With Mule ESB
Using Jolokia and Hawtio With Mule ESB
An integration developer goes over a fast, easy approach to integrating Mule ESB with the Jolokia monitoring agent and Hawtio.
Join the DZone community and get the full member experience.Join For Free
The new Gartner Critical Capabilities report explains how APIs and microservices enable digital leaders to deliver better B2B, open banking and mobile projects.
Monitoring made simple with Jolokia Mule plugin
Monitoring is an essential component for ensuring the proper functioning of microservices. As the complexity of software systems increases, it becomes more difficult to understand performance characteristics and to troubleshoot problems. The monitoring tools we use may also need to be adaptable to new deployment strategies and environments.
Jolokia is a JMX-HTTP bridge giving an alternative to JSR-160 connectors. It's an agent-based approach with support for many platforms. In addition to basic JMX operations, it enhances JMX remoting with unique features like bulk requests and fine-grained security policies.
This paper describes how we might utilize Open Source Jolokia as a monitoring agent for Mule. The Mule ESB has historically used the Mule Management Console (MMC) to monitor internal flow and performance characteristics.
As we start pushing out the Mule runtime as a container based solution, we'll need to give careful thought to an appropriate monitoring strategy. Here we'll consider one, the Jolokia JMX Mule Agent plugin.
The Jolokia client runs as a browser-based instance from a Jar implementation to
communicate with the monitoring server we'll embed in the Mule runtime. The
Jolokia Agent is able to communicate over various protocols such as RMI, SOAP,
and JMX depicted in the diagram below.
Jolokia Client/Agent architecture
Mule monitoring information, properties, and statistics will be made available to the Jolokia Client through JMX Managed Beans (MBeans). The details are important if you plan to expose custom monitoring data to your clients.
For more information on how to customize your data, see the Jolokia Documentation.
This installation will require two parts, the Jolokia Agent which we'll embed in the Mule Runtime and a client piece which will use Hawtio to provide browser access to the Jolokia agent.
Embedding Jolokia in Mule
Start by downloading the agent from here - Jolokia Mule Download.
The snapshot below shows the latest version I had pulled for this article; if the version has changed
since then, download the latest version.
Download the Jolokia/Mule Agent Jar
After downloading the Jolokia Mule Agent jar file, it needs to be stored in the Mule installation root optional libs folder (in
Next, we'll embed the Jolokia Agent into the Mule default stub. Using your favorite editor, go ahead and make the changes to the mule-config.xml, ensure that the XML namespace is consistent with the example.
Add the following Jolokia Agent reference to the apps/default/mule-config.xml
<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:management="http://www.mulesoft.org/schema/mule/management" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd http://www.mulesoft.org/schema/mule/management http://www.mulesoft.org/schema/mule/management/current/mule-management.xsd"> <--1--> <!-- Wire in Mule Jolokia Agent --> <custom-agent name="jolokia-agent" class="org.jolokia.mule.JolokiaMuleAgent"> <spring:property name="port" value="8899"/> <--2--> <!-- Uncomment to enable access control <spring:property name="user" value="mulokia"/> <spring:property name="password" value="secret"/> --> </custom-agent> </mule>
Add in the reference for the Jolokia Agent.
Enable access control.
With the mule-config.xml file updated with the reference to the *jolokia-agent*, we can open the firewall port the agent listens on and send a request from the browser.
Open Agent firewall Port
Open port 8899 for Jolokia agent
The procedure for opening the port will be different depending on whether your application is running in AWS, a Docker container, a standalone Unix instance, or your desktop/laptop.
I'll leave it as an exercise for you to solve with Google; if you really need help, add a comment with your platform information and what you've tried.
Download the Hawtio Client
Use the link below to download the Hawtio application.
Whew, that was easy!
Let's move on to configuring and starting.
Let's start by configuring a script that will start up Hawtio. Using whatever process you use to
find your support jars, add the Hawtio app jar you just downloaded to that location. Here's an example script I use to start the Hawtio app:
Hawtio batch file hawt.bat
%echo off% set HAWT_PATH=/Tools/Java/Jars/hawtio-app-1.5.4.jar <1> set HAWT_PORT=8087<2> java -Dhawtio.proxyWhitelist=* -Dhawtio.authenticationEnabled=false -jar %HAWT_PATH% --port %HAWT_PORT%
I keep my non-Maven/Gradle service jars in
c:\Tools\java\Jars; you can use Unix file path naming conventions and Java will find them.
Pick a free port number for Jetty to use for the Hawtio application.
These same notes apply to the Bash script for Unix users below.
Hawtio script file hawt
#!/bin/bash export HAWT_PATH=$HOME/Java/Jars/hawtio-app-1.5.4.jar export HAWT_PORT=8087 java -Dhawtio.proxyWhitelist=* -Dhawtio.authenticationEnabled=false -jar $HAWT_PATH --port $HAWT_PORT
Hawtio will start up a Jetty server on the port you specified in the configuration, then
it will start a browser session connecting to the startup URI.
Run your script
The Welcome page serves to get beginners oriented with Hawtio. Click on the Connect menu option.
Jolokia connection settings:
Hawtio Connection Parameters
If your Mule instance isn't local, be sure to enter the Domain Name or IP address and make sure port 8899 is open on the Mule host.
Now for the fun part, when your connection request succeeds, you'll get a new browser display like this:
Hawtio Main screen
Hawtio supports various plugins that you can add to the application. Feel free to explore the various menu options and get familiar with all the capabilities.
I hope you enjoyed reading this article as much as I have enjoyed writing it, I'm looking forward to your comments!
Opinions expressed by DZone contributors are their own.