-
Notifications
You must be signed in to change notification settings - Fork 349
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
549 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
== Jolokia Example | ||
|
||
This example shows how Camel can be monitored and managed using https://jolokia.org[Jolokia] and https://hawt.io[Hawtio] | ||
|
||
=== How to run | ||
|
||
You can run this example using | ||
|
||
mvn spring-boot:run | ||
|
||
=== Run Hawtio | ||
|
||
Hawtio is a lightweight and modular Web console for managing Java applications. | ||
It can be installed/used in more ways, see https://hawt.io/docs/get-started.html[Get Started Guide] | ||
|
||
In the example I am suggesting the jbang way to install it | ||
|
||
jbang app install hawtio@hawtio/hawtio | ||
hawtio --port 8090 | ||
|
||
=== Connect to the application | ||
|
||
Open Hawtio UI at http://localhost:8090/hawtio/connect/remote[] and click on `Add connection` button filling the properties as in the picture | ||
|
||
- Name: `as you prefer [eg camel]` | ||
- Scheme: `http` | ||
- Host: `localhost` | ||
- Port: `8778` | ||
- Path: `/jolokia/` | ||
|
||
image::docs/add-connection.png[] | ||
|
||
click on `Add` button, this action will create a connection in the list of the connections, | ||
then connect on it clicking on the button `Connect` | ||
|
||
then it is possible to monitor and to manage routes | ||
|
||
image::docs/route-monitor.png[] | ||
|
||
=== Configure Jolokia endpoint | ||
|
||
The Jolokia autoconfiguration is an alternative to the Jolokia agent, | ||
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] | ||
|
||
=== Help and contributions | ||
|
||
If you hit any problem using Camel or have some feedback, then please | ||
https://camel.apache.org/community/support/[let us know]. | ||
|
||
We also love contributors, so | ||
https://camel.apache.org/community/contributing/[get involved] :-) | ||
|
||
The Camel riders! |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Licensed to the Apache Software Foundation (ASF) under one or more | ||
contributor license agreements. See the NOTICE file distributed with | ||
this work for additional information regarding copyright ownership. | ||
The ASF licenses this file to You under the Apache License, Version 2.0 | ||
(the "License"); you may not use this file except in compliance with | ||
the License. You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<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"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<artifactId>examples</artifactId> | ||
<groupId>org.apache.camel.springboot.example</groupId> | ||
<version>4.9.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>camel-example-spring-boot-jolokia</artifactId> | ||
<name>Camel SB Examples :: Jolokia</name> | ||
<description>An example that uses Jolokia to monitor and to manage Camel Routes</description> | ||
<packaging>jar</packaging> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<category>Management and Monitoring</category> | ||
</properties> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<!-- Camel BOM --> | ||
<dependency> | ||
<groupId>org.apache.camel.springboot</groupId> | ||
<artifactId>camel-spring-boot-bom</artifactId> | ||
<version>${project.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
<!-- Spring Boot BOM --> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-dependencies</artifactId> | ||
<version>${spring-boot-version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<dependencies> | ||
|
||
<!-- Spring Boot --> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-actuator</artifactId> | ||
</dependency> | ||
|
||
<!-- Camel --> | ||
<dependency> | ||
<groupId>org.apache.camel.springboot</groupId> | ||
<artifactId>camel-spring-boot-starter</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.camel.springboot</groupId> | ||
<artifactId>camel-stream-starter</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.camel.springboot</groupId> | ||
<artifactId>camel-jolokia-starter</artifactId> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
<version>${spring-boot-version}</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>repackage</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
38 changes: 38 additions & 0 deletions
38
jolokia/src/main/java/org/apache/camel/example/MySpringBean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.camel.example; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Component; | ||
|
||
/** | ||
* A bean that returns a message when you call the {@link #saySomething()} method. | ||
* <p/> | ||
* Uses <tt>@Component("myBean")</tt> to register this bean with the name <tt>myBean</tt> | ||
* that we use in the Camel route to lookup this bean. | ||
*/ | ||
@Component("myBean") | ||
public class MySpringBean { | ||
|
||
@Value("${greeting}") | ||
private String say; | ||
|
||
public String saySomething() { | ||
return say; | ||
} | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
jolokia/src/main/java/org/apache/camel/example/MySpringBootApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.camel.example; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class MySpringBootApplication { | ||
|
||
/** | ||
* A main method to start this application. | ||
*/ | ||
public static void main(String[] args) { | ||
SpringApplication.run(MySpringBootApplication.class, args); | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
jolokia/src/main/java/org/apache/camel/example/MySpringBootRouter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.camel.example; | ||
|
||
import org.apache.camel.builder.RouteBuilder; | ||
import org.springframework.stereotype.Component; | ||
|
||
/** | ||
* A simple Camel route that triggers from a timer and calls a bean and prints to system out. | ||
* <p/> | ||
* Use <tt>@Component</tt> to make Camel auto detect this route when starting. | ||
*/ | ||
@Component | ||
public class MySpringBootRouter extends RouteBuilder { | ||
|
||
@Override | ||
public void configure() { | ||
from("timer:hello?period={{timer.period}}").routeId("hello") | ||
.transform().method("myBean", "saySomething") | ||
.filter(simple("${body} contains 'foo'")) | ||
.to("log:foo") | ||
.end() | ||
.to("stream:out"); | ||
} | ||
|
||
} |
Oops, something went wrong.