How to monitor Apache camel routes in a Java project using hawtio
Asked Answered
P

3

6

Usually if we develop a java camel application using Java DSL then its very difficult to monitor the camel routs. To check whether the routes are running or not we need an extra monitoring application need to be developed.

But Hawtio ease our work in that. If your project is web application project then Hawtio has already camel component for it. So with out any extra efforts it will directy work.

But for Java Application it is not showing the routes.

Profanatory answered 10/2, 2018 at 15:4 Comment(0)
P
2

When we develop a java camel application we need some extra works to be done in order to view the routs.

Steps for configuring java related camel application on hawtio

  1. Download the hawtio from https://hawt.io/getstarted/ enter image description here

  2. Place the war file in tomcat webapps folder --> start the tomcat web server. ( If you don’t have tomcat then please download the same from https://tomcat.apache.org/download-80.cgi )

Goto: http://localhost:8080/sample-1.5.6/welcome to view the hawtio enter image description here Note: At the first time there will be no Container tab.

  1. To make use of hawtio in JVM (for java related application) we use Jolokia. Download Jolokia from https://jolokia.org/download.html

enter image description here

  1. Command to attach Jolokia on the fly (No code changes required). We can use same jar file for deployment purposes.

Use the following command line argument:

    java <location of Jolokia agent.jar file> =host=0.0.0.0 -jar <location of our jar file>

Example:

    java -javaagent:jolokia-jvm-1.4.0-agent.jar=host=0.0.0.0 -jar C:\Users\HackoMan\Documents\GitHub\target\myjar-1.0-SNAPSHOT.jar

enter image description here

  1. Goto: http://localhost:8080/sample-1.5.6/welcome hawtio --> Connect --> Discovery --> press run/play button as mentioned below.

  2. This opens a new tab. Press camel tab to view all of our route.

Then click on any route that either you want to debug or trace or to find details about it. enter image description here enter image description here

Profanatory answered 10/2, 2018 at 15:23 Comment(2)
Can you update answer for spring boot and for new update in hawtio.Entablement
@ShibinRajuMathew Hi, sorry, cant help much in this case. I have not worked on spring boot(other than rest service creation)Profanatory
C
2

I was stuck doing this. After reading some documentation and blogs I could monitor Camel routes using Hawtio.

  • Spring Boot 2.3.4.RELEASE
  • Camel 3.4.3
  • Hawtio 2.10.1

Dependencies

For Spring Boot, it's not necessary if you already have conifgured the project.

Auto-detects camel routes in Spring Context and register Camel utilities (like producer template, consumer template and the type converter) as beans.

    <dependency>
        <groupId>org.apache.camel.springboot</groupId>
        <artifactId>camel-spring-boot</artifactId>
        <version>${camel.version}</version>
    </dependency>

To have support for auto-configuration from properties

    <dependency>
        <groupId>org.apache.camel.springboot</groupId>
        <artifactId>camel-spring-boot-starter</artifactId>
        <version>${camel.version}</version>
    </dependency>

For manage routes using Jolokia as agent.

To allow camel routes been manage by jolokia

    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-management</artifactId>
        <version>${camel.version}</version>
    </dependency>

To run jolokia and expose metrics over Http

    <dependency>
        <groupId>org.jolokia</groupId>
        <artifactId>jolokia-core</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

Properties

Expose Jolokia endpoint

management.endpoints.web.exposure.include=jolokia

For not to use the word "actuator" as part of the endpoint when exposing jolokia

management.endpoints.web.base-path=/

For configuring Jolokia endpoint path

management.endpoints.web.path-mapping.jolokia=medidas

For setting custom port

server.port=8778

Finally

  1. Start the project

  2. Start Hawtio

    java -jar hawtio-app-2.10.1.jar

  3. In web broser

    http://localhost:8080/hawtio

  4. Configure the connection, test the connection.

    Connection Picture

  1. The last step is connect and automatically you will see camel routes
Categorical answered 19/10, 2021 at 18:10 Comment(0)
M
1

Add follwoing dependency to spring boot app.

  <dependency>
      <groupId>io.hawt</groupId>
      <artifactId>hawtio-springboot</artifactId>
 </dependency>

Add following properties for getting started without auth.

hawtio.authenticationEnabled = false
hawtio.offline = true

Complete example available over here:

https://github.com/jinternals/camel/

Mend answered 3/11, 2018 at 13:20 Comment(1)
What is hawtio.offline for?Roden

© 2022 - 2024 — McMap. All rights reserved.