Skip to content

Commit 7d8bea2

Browse files
committed
CAMEL-21348: Adds jolokia example (apache#144)
1 parent 3db5f82 commit 7d8bea2

File tree

12 files changed

+631
-9
lines changed

12 files changed

+631
-9
lines changed

README.adoc

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ to the SNAPSHOT version of the next release.
1515

1616
To execute the examples, checkout into the tag for the latest release. For example:
1717

18-
`$ git checkout tags/camel-spring-boot-examples-3.5.0`
18+
`$ git checkout tags/camel-spring-boot-examples-4.8.0`
1919

2020
Then, install the root pom:
2121

@@ -27,15 +27,15 @@ readme's instructions.
2727
=== Examples
2828

2929
// examples: START
30-
Number of Examples: 60 (0 deprecated)
30+
Number of Examples: 61 (0 deprecated)
3131

3232
[width="100%",cols="4,2,4",options="header"]
3333
|===
3434
| Example | Category | Description
3535

3636
| link:amqp-salesforce/README.adoc[Amqp Salesforce] (amqp-salesforce) | | AMQP message sending is created as contacts in Salesforce
3737

38-
| link:health-checks/readme.adoc[Health Checks] (health-checks) | |
38+
| link:health-checks/readme.adoc[Health Checks] (health-checks) | |
3939

4040
| link:spring-boot-jta-jpa-autoconfigure/readme.adoc[Spring Boot Jta Jpa Autoconfigure] (spring-boot-jta-jpa-autoconfigure) | Advanced | An example showing JTA with Spring Boot Autoconfiguration
4141

@@ -115,17 +115,21 @@ Number of Examples: 60 (0 deprecated)
115115

116116
| link:actuator-http-metrics/readme.adoc[Actuator Http Metrics] (actuator-http-metrics) | Management and Monitoring | Example on how to use Spring Boot's Actuator endpoints to gather info like mappings or metrics
117117

118+
| link:health-checks/readme.adoc[Health Checks] (health-checks) | Management and Monitoring | An example how to use custom health-checks
119+
120+
| link:jolokia/README.adoc[Jolokia] (jolokia) | Management and Monitoring | An example that uses Jolokia to monitor and to manage Camel Routes
121+
118122
| link:metrics/README.adoc[Metrics] (metrics) | Management and Monitoring | An example showing how to work with Camel and Spring Boot and report metrics to Graphite
119123

120124
| link:monitoring-micrometrics-grafana-prometheus/Readme.adoc[Monitoring Micrometrics Grafana Prometheus] (monitoring-micrometrics-grafana-prometheus) | Management and Monitoring | Example on how to use Spring Boot's Actuator endpoints to
121125
gather info like mappings or metrics
122-
126+
123127

124128
| link:observation/README.adoc[Micrometer Observation] (observation) | Management and Monitoring | An example showing how to trace incoming and outgoing messages from Camel with Micrometer Observation
125129

126130

127-
| link:opentelemetry/README.adoc[OpenTelemetry] (opentelemetry) | Management and Monitoring | An example showing how to use Camel with OpenTelemetry
128-
131+
| link:opentelemetry/README.adoc[OpenTelemetry] (opentelemetry) | Management and Monitoring | An example showing how to use Camel with OpenTelemetry
132+
129133

130134
| link:supervising-route-controller/readme.adoc[Supervising Route Controller] (supervising-route-controller) | Management and Monitoring | An example showing how to work with Camel's Supervising Route Controller and Spring Boot
131135

@@ -145,7 +149,7 @@ Number of Examples: 60 (0 deprecated)
145149

146150
| link:strimzi/README.adoc[Strimzi] (strimzi) | Messaging | Camel example which a route is defined in XML for Strimzi
147151
integration on Openshift/Kubernetes
148-
152+
149153

150154
| link:widget-gadget/README.adoc[Widget Gadget] (widget-gadget) | Messaging | The widget and gadget example from EIP book, running on Spring Boot
151155

@@ -178,7 +182,7 @@ Number of Examples: 60 (0 deprecated)
178182

179183
- Create an odo component using the devfile.yaml
180184

181-
$ odo create csb-ubi8 --app $EXAMPLE
185+
$ odo create csb-ubi8 --app $EXAMPLE
182186

183187
- To set the specific example you want to deploy as an env variable (SUB_FOLDER):
184188

@@ -188,7 +192,7 @@ Number of Examples: 60 (0 deprecated)
188192

189193
$ odo push
190194

191-
=== Note:
195+
=== Note:
192196

193197
- Only few examples can be deployed using devfile:
194198

jolokia/README.adoc

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
== Jolokia Example
2+
3+
This example shows how Camel can be monitored and managed using https://jolokia.org[Jolokia] and https://hawt.io[Hawtio]
4+
5+
=== How to run
6+
7+
You can run this example using
8+
9+
mvn spring-boot:run
10+
11+
=== Run Hawtio
12+
13+
Hawtio is a lightweight and modular Web console for managing Java applications.
14+
It can be installed/used in more ways, see https://hawt.io/docs/get-started.html[Get Started Guide]
15+
16+
In the example I am suggesting the jbang way to install it
17+
18+
jbang app install hawtio@hawtio/hawtio
19+
hawtio --port 8090
20+
21+
=== Connect to the application
22+
23+
Open Hawtio UI at http://localhost:8090/hawtio/connect/remote[] and click on `Add connection` button filling the properties as in the picture
24+
25+
- Name: `as you prefer [eg camel]`
26+
- Scheme: `http`
27+
- Host: `localhost`
28+
- Port: `8778`
29+
- Path: `/jolokia/`
30+
31+
image::docs/add-connection.png[]
32+
33+
click on `Add` button, this action will create a connection in the list of the connections,
34+
then connect on it clicking on the button `Connect`
35+
36+
then it is possible to monitor and to manage routes
37+
38+
image::docs/route-monitor.png[]
39+
40+
=== Configure Jolokia endpoint
41+
42+
The Jolokia autoconfiguration is an alternative to the Jolokia agent,
43+
more information about the usage and the configuration can be found on https://github.com/apache/camel-spring-boot/blob/main/components-starter/camel-jolokia-starter/src/main/docs/jolokia.adoc[component guide]
44+
45+
=== How to run on OpenShift cluster
46+
47+
1. create openshift project:
48+
49+
oc new-project camel-jolokia
50+
51+
2. install Hawtio operator in the camel-jolokia namespace according to the documentation
52+
https://docs.redhat.com/en/documentation/red_hat_build_of_apache_camel/4.4/html/hawtio_diagnostic_console_guide/setting-up-hawtio-on-openshift-4#installing-and-deploying-hawtio-on-openshift-4-by-using-operatorhub[Installing and deploying HawtIO on OpenShift 4 by using the OperatorHub]
53+
54+
3. create Hawtio instance, default from UI is fine:
55+
56+
cat <<EOF | oc apply -f -
57+
apiVersion: hawt.io/v1
58+
kind: Hawtio
59+
metadata:
60+
name: hawtio-online
61+
namespace: camel-jolokia
62+
spec:
63+
resources:
64+
limits:
65+
cpu: '1'
66+
memory: 200Mi
67+
requests:
68+
cpu: 200m
69+
memory: 32Mi
70+
auth:
71+
clientCertCheckSchedule: '* */12 * * *'
72+
clientCertExpirationPeriod: 24
73+
replicas: 1
74+
type: Namespace
75+
EOF
76+
77+
4. deploy application
78+
79+
mvn clean install -Popenshift
80+
81+
5. access to Hawtio UI console using url
82+
83+
echo "https://$(oc get route hawtio-online -o go-template --template='{{.spec.host}}')/online/discover"
84+
85+
6. The application `camel-example-spring-boot-jolokia` should be available to the connection
86+
using the `Connect` button. Please refer to the guide
87+
https://docs.redhat.com/en/documentation/red_hat_build_of_apache_camel/4.4/html/hawtio_diagnostic_console_guide/viewing-and-managing-apache-camel-applications#starting_suspending_or_deleting_a_context[Viewing and managing Apache Camel applications]
88+
for additional details
89+
90+
=== Help and contributions
91+
92+
If you hit any problem using Camel or have some feedback, then please
93+
https://camel.apache.org/community/support/[let us know].
94+
95+
We also love contributors, so
96+
https://camel.apache.org/community/contributing/[get involved] :-)
97+
98+
The Camel riders!

jolokia/docs/add-connection.png

44.5 KB
Loading

jolokia/docs/route-monitor.png

63.6 KB
Loading

jolokia/pom.xml

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Licensed to the Apache Software Foundation (ASF) under one or more
5+
contributor license agreements. See the NOTICE file distributed with
6+
this work for additional information regarding copyright ownership.
7+
The ASF licenses this file to You under the Apache License, Version 2.0
8+
(the "License"); you may not use this file except in compliance with
9+
the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
21+
22+
<modelVersion>4.0.0</modelVersion>
23+
24+
<parent>
25+
<artifactId>examples</artifactId>
26+
<groupId>org.apache.camel.springboot.example</groupId>
27+
<version>4.8.0-SNAPSHOT</version>
28+
</parent>
29+
30+
<artifactId>camel-example-spring-boot-jolokia</artifactId>
31+
<name>Camel SB Examples :: Jolokia</name>
32+
<description>An example that uses Jolokia to monitor and to manage Camel Routes</description>
33+
<packaging>jar</packaging>
34+
35+
<properties>
36+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
37+
<category>Management and Monitoring</category>
38+
</properties>
39+
40+
<dependencyManagement>
41+
<dependencies>
42+
<dependency>
43+
<groupId>com.redhat.camel.springboot.platform</groupId>
44+
<artifactId>camel-spring-boot-bom</artifactId>
45+
<version>${camel-spring-boot-version}</version>
46+
<type>pom</type>
47+
<scope>import</scope>
48+
</dependency>
49+
</dependencies>
50+
</dependencyManagement>
51+
52+
<dependencies>
53+
54+
<!-- Spring Boot -->
55+
<dependency>
56+
<groupId>org.springframework.boot</groupId>
57+
<artifactId>spring-boot-starter-web</artifactId>
58+
<exclusions>
59+
<exclusion>
60+
<groupId>org.springframework.boot</groupId>
61+
<artifactId>spring-boot-starter-tomcat</artifactId>
62+
</exclusion>
63+
</exclusions>
64+
</dependency>
65+
<dependency>
66+
<groupId>org.springframework.boot</groupId>
67+
<artifactId>spring-boot-starter-undertow</artifactId>
68+
</dependency>
69+
<dependency>
70+
<groupId>org.springframework.boot</groupId>
71+
<artifactId>spring-boot-starter-actuator</artifactId>
72+
</dependency>
73+
74+
<!-- Camel -->
75+
<dependency>
76+
<groupId>org.apache.camel.springboot</groupId>
77+
<artifactId>camel-spring-boot-starter</artifactId>
78+
</dependency>
79+
<dependency>
80+
<groupId>org.apache.camel.springboot</groupId>
81+
<artifactId>camel-stream-starter</artifactId>
82+
</dependency>
83+
<dependency>
84+
<groupId>org.apache.camel.springboot</groupId>
85+
<artifactId>camel-jolokia-starter</artifactId>
86+
</dependency>
87+
88+
</dependencies>
89+
90+
<build>
91+
<plugins>
92+
<plugin>
93+
<groupId>org.springframework.boot</groupId>
94+
<artifactId>spring-boot-maven-plugin</artifactId>
95+
<version>${spring-boot-version}</version>
96+
<executions>
97+
<execution>
98+
<goals>
99+
<goal>repackage</goal>
100+
</goals>
101+
</execution>
102+
</executions>
103+
</plugin>
104+
</plugins>
105+
</build>
106+
107+
<profiles>
108+
<profile>
109+
<id>openshift</id>
110+
<build>
111+
<defaultGoal>install</defaultGoal>
112+
<plugins>
113+
<plugin>
114+
<groupId>org.eclipse.jkube</groupId>
115+
<artifactId>openshift-maven-plugin</artifactId>
116+
<version>${jkube-maven-plugin-version}</version>
117+
<executions>
118+
<execution>
119+
<goals>
120+
<goal>resource</goal>
121+
<goal>build</goal>
122+
<goal>apply</goal>
123+
</goals>
124+
</execution>
125+
</executions>
126+
</plugin>
127+
</plugins>
128+
</build>
129+
</profile>
130+
</profiles>
131+
132+
</project>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.camel.example;
18+
19+
import org.springframework.beans.factory.annotation.Value;
20+
import org.springframework.stereotype.Component;
21+
22+
/**
23+
* A bean that returns a message when you call the {@link #saySomething()} method.
24+
* <p/>
25+
* Uses <tt>@Component("myBean")</tt> to register this bean with the name <tt>myBean</tt>
26+
* that we use in the Camel route to lookup this bean.
27+
*/
28+
@Component("myBean")
29+
public class MySpringBean {
30+
31+
@Value("${greeting}")
32+
private String say;
33+
34+
public String saySomething() {
35+
return say;
36+
}
37+
38+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.camel.example;
18+
19+
import org.springframework.boot.SpringApplication;
20+
import org.springframework.boot.autoconfigure.SpringBootApplication;
21+
22+
@SpringBootApplication
23+
public class MySpringBootApplication {
24+
25+
/**
26+
* A main method to start this application.
27+
*/
28+
public static void main(String[] args) {
29+
SpringApplication.run(MySpringBootApplication.class, args);
30+
}
31+
32+
}

0 commit comments

Comments
 (0)