Published on

Manage and monitor Camel Quarkus applications with Jolokia

Authors
  • avatar
    Name
    James Netherton
    Twitter

The Jolokia extension was introduced in Camel Quarkus 3.19.0, initially only with JVM mode. In 3.20.0, it now comes with native mode support.

Similar to its Camel Spring Boot starter counterpart, it enables Camel Quarkus applications to be remotely managed and monitored using Hawtio.

If you're unfamiliar with Jolokia, it's an JMX-HTTP bridge allowing applications to read JMX MBean attributes, invoke operations etc over HTTP.

Getting started

The first step is to add the camel-quarkus-jolokia dependency to your application.

<dependency>
  <groupId>org.apache.camel.quarkus</groupId>
  <artifactId>camel-quarkus-jolokia</artifactId>
</dependency>

To test it, run the development mode.

mvn clean quarkus:dev

In a separate terminal session, interact with the Jolokia HTTP endpoint. Note, if you do not have jq installed then simply remove it from the command below.

curl localhost:8778/jolokia/ | jq

You'll see a JSON response with some basic information about the Jolokia configuration.

The Jolokia endpoint is also available as a Quarkus management endpoint under the /q context path.

curl -L localhost:8778/q/jolokia | jq

Hawtio

Hawtio is a modular web console for managing Java applications. It has great support for Camel, so lets harness its power to manage a simple Camel Quarkus demo.

The source code for the demo application can be found at the following location.

https://github.com/jamesnetherton/camel-quarkus-demos/jolokia

Start the application in development mode.

mvn clean quarkus:dev

Next start Hawtio. There's a few different ways of doing this. I find it simplest to use JBang.

jbang app install hawtio@hawtio/hawtio
hawtio --port=8085

A browser window will open and the Hawtio connect page will be displayed. Click the 'Discover' button and connect to the camel-quarkus-jolokia-demo application.

hawtio-discovery

You'll now be able to view details about the running application.

hawtio-camel-route

You can also package and run the application in JVM mode via the runnable JAR.

mvn clean package
java -jar target/quarkus-app/quarkus-run.jar

NOTE: Hawtio also has a dedicated Quarkus dependency where its UI and Jolokia endpoint are embedded within the application. Unlike this example where we use Hawtio to connect to an external Jolokia endpoint.

Native mode

In addition to above, it's possible to have Jolokia working in native mode and Hawtio can connect to a native application!

First, package and run the native application.

mvn clean package -Dnative
target/*-runner

Next connect to the application with Hawtio as per the instructions above. There are a few limitations with JMX in native mode which are documented here.

Camel Quarkus with Hawtio on Kubernetes & OpenShift

If you deploy your Camel Quarkus applications on Kubernetes or OpenShift, then Camel Quarkus & Hawtio has you covered. By installing Hawtio Online, you can view and connect to any Camel Quarkus application where Jolokia is present.

On OpenShift, there is a 'one click' install of Hawtio via OperatorHub.

hawtio-online-operator

Or alternatively, follow the instructions in the documentation.

For Kubernetes, follow the instructions in the Hawtio Online documentation.

With Hawtio Online installed, you can visit its home page. On OpenShift you can get the URL with oc get route hawtio-online.

When there are no applications deployed, the initial view will be empty. We'll change that by deploying the demo application to the cluster.

mvn clean package -DskipTests -Dquarkus.Kubernetes.deploy=true

Eventually, after the application is deploy successfully, it should be listed in the Hawtio Online application listing. Click 'Connect' to start managing the application.

hawtio-online-app

Other MBean domains

To widen the site of MBeans that are available to Jolokia, you can override the default list with your own by adding a configuration property to application.properties.

quarkus.camel.jolokia.camel-restrictor-allowed-mbean-domains=org.apache.camel,my.package,my.other.package

Conclusion

Hopefully this brief overview of the Camel camel-quarkus-jolokia is helpful in showing how some of the basic functionality works.

Check out the extension documentation for more information.

Happy coding!