이 콘텐츠는 선택한 언어로 제공되지 않습니다.

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
Copy to Clipboard Toggle word wrap

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
    Copy to Clipboard Toggle word wrap
  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
    Copy to Clipboard Toggle word wrap

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>
    Copy to Clipboard Toggle word wrap

    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
    Copy to Clipboard Toggle word wrap

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
          ........
      .......
Copy to Clipboard Toggle word wrap

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
    Copy to Clipboard Toggle word wrap

    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

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2026 Red Hat
맨 위로 이동