Questo contenuto non è disponibile nella lingua selezionata.

Chapter 7. Setting up Spring Boot applications for HawtIO Online with Jolokia


Note

If stopping a Camel route is changing the health status to DOWN and triggering a pod restart by OpenShift, a possible solution to avoid this behavior is to set:

camel.routecontroller.enabled = true

It will enable the supervised route controller so that the route will be with status Stopped and the overall status of the health check is UP.

This section describes the enabling of monitoring of a Spring Boot application by HawtIO. It starts from first principles in setting up a simple example application.

Note

This application runs on OpenShift and is discovered and monitored by HawtIO online.

If you already have a Spring Boot application implemented, skip to Section 7.2, “Adding Jolokia Starter dependency to the application”.

Note

The following is based on the jolokia sample application in the Apache Camel Spring-Boot examples repository.

Prerequisites

  • Maven has been installed and mvn is available on the Command-line (CLI).

7.1. Setting up a sample Spring Boot application

To create a new Spring Boot application, you can either create the maven project directory structure manually, or execute an archetype to generate the scaffolding for a standard java project, which you can customize for individual applications.

  1. Customize these values as needed:

    archetypeVersion
    4.10.3.redhat-00019
    groupId
    io.hawtio.online.examples
    artifactId
    hawtio-online-example-camel-springboot-os
    version
    1.0.0
  2. Run the maven archetype:

    mvn archetype:generate  \
      -DarchetypeGroupId=org.apache.camel.archetypes  \
      -DarchetypeArtifactId=camel-archetype-spring-boot  \
      -DarchetypeVersion=4.10.3.redhat-00019  \
      -DgroupId=io.hawt.online.examples  \
      -DartifactId=hawtio-online-example  \
      -Dversion=1.0.0  \
      -DinteractiveMode=false \
      -Dpackage=io.hawtio
  3. Change into the new project named artifactId (in the above example: hawtio-online-example)

    An example hello world application is created, and you can compile it.

    At this point, the application should be executable locally.

  1. Use the mvn spring-boot:run maven goal to test the application:

    $ mvn spring-boot:run

7.2. Adding Jolokia Starter dependency to the application

In order to allow HawtIO to monitor the Camel route in the application, you must add the camel-jolokia-starter dependency. It contains all the necessary transitive dependencies.

  1. Add the needed dependencies to the <dependencies> section:

    <dependencies>
      ...
    
      <!-- Camel -->
      ...
    
      <!-- Dependency is mandatory for exposing Jolokia endpoint -->
      <dependency>
          <groupId>org.apache.camel.springboot</groupId>
          <artifactId>camel-jolokia-starter</artifactId>
      </dependency>
    
      <!-- Optional: enables debugging support for Camel -->
      <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-debug</artifactId>
        <version>4.10.3</version>
     </dependency>
    
    ...
    </dependencies>

    For configuration details, see the Jolokia component documentation

  1. To enable inflight monitoring also add the following property to the application.properties file according to the Spring Boot documentation:

    camel.springboot.inflight-repository-browse-enabled=true

7.3. Configuring the application for Deployment to OpenShift

The starter already manages the configuration for the Kubernetes/OpenShift environment, so no specific extra configuration is needed.

The only mandatory configuration is the name of the port exposed by the POD, it must be named jolokia.

spec:
  containers:
    - name: my-container
      ports:
        - name: jolokia
          containerPort: 8778
          protocol: TCP
          ........
      .......

7.4. Deploying the Spring Boot application to OpenShift

  1. Prerequisites

    • The appropriate project selected (see Documentation);
    • All files have been configured.
  2. Run the following maven command:

    mvn clean install -DskipTests -P openshift

    The application is compiled with S2I and deployed to OpenShift.

  1. Verify that the Spring Boot application is running correctly:

    Follow the Verification steps detailed in the Deploying Red Hat build of Quarkus Java applications to OpenShift Container Platform section of the Red Hat build of Quarkus documentation.

  2. When your new Spring Boot application is running correctly, it is discovered by the HawtIO instance (depending on its mode - 'Namespace' mode requires it to be in the same project).

    The new container should be displayed like in the following screenshot:

    springboot example pod listing
  1. Click Connect to examine the Spring Boot application can be with HawtIO:

    springboot example connection ui
Red Hat logoGithubredditYoutubeTwitter

Formazione

Prova, acquista e vendi

Community

Informazioni sulla documentazione di Red Hat

Aiutiamo gli utenti Red Hat a innovarsi e raggiungere i propri obiettivi con i nostri prodotti e servizi grazie a contenuti di cui possono fidarsi. Esplora i nostri ultimi aggiornamenti.

Rendiamo l’open source più inclusivo

Red Hat si impegna a sostituire il linguaggio problematico nel codice, nella documentazione e nelle proprietà web. Per maggiori dettagli, visita il Blog di Red Hat.

Informazioni su Red Hat

Forniamo soluzioni consolidate che rendono più semplice per le aziende lavorare su piattaforme e ambienti diversi, dal datacenter centrale all'edge della rete.

Theme

© 2026 Red Hat
Torna in cima