-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* http-log example * Add license header * Add some scripts for the example * Turn off banner * Fix license header
- Loading branch information
Showing
9 changed files
with
493 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
= http-log | ||
|
||
This is a basic hello world example that uses CDI and JAX-RS to setup | ||
a REST service and a Camel route to service HTTP traffic. | ||
|
||
TIP: Check the https://camel.apache.org/camel-quarkus/latest/first-steps.html[Camel Quarkus User guide] for prerequisites | ||
and other general information. | ||
|
||
== Start in the Development mode | ||
|
||
[source,shell] | ||
---- | ||
$ mvn clean compile quarkus:dev -DnoDeps | ||
---- | ||
|
||
The above command compiles the project, starts the application and lets the Quarkus tooling watch for changes in your | ||
workspace. Any modifications in your project will automatically take effect in the running application. | ||
|
||
TIP: Please refer to the Development mode section of | ||
https://camel.apache.org/camel-quarkus/latest/first-steps.html#_development_mode[Camel Quarkus User guide] for more details. | ||
|
||
You can from a web browser call the two services via | ||
|
||
- http://localhost:8080/hello | ||
- http://localhost:8080/camel/hello | ||
|
||
There is also health check and metrics available from the following urls: | ||
|
||
- http://localhost:8080/health | ||
- http://localhost:8080/metrcis | ||
|
||
=== Package and run the application | ||
|
||
Once you are done with developing you may want to package and run the application. | ||
|
||
TIP: Find more details about the JVM mode and Native mode in the Package and run section of | ||
https://camel.apache.org/camel-quarkus/latest/first-steps.html#_package_and_run_the_application[Camel Quarkus User guide] | ||
|
||
==== JVM mode | ||
|
||
[source,shell] | ||
---- | ||
$ mvn clean package | ||
$ java -jar target/*-runner.jar | ||
... | ||
[io.quarkus] (main) Quarkus 0.23.2 started in 1.163s. Listening on: http://[::]:8080 | ||
---- | ||
|
||
==== Native mode | ||
|
||
IMPORTANT: Native mode requires having GraalVM and other tools installed. Please check the Prerequisites section | ||
of https://camel.apache.org/camel-quarkus/latest/first-steps.html#_prerequisites[Camel Quarkus User guide]. | ||
|
||
To prepare a native executable using GraalVM, run the following command: | ||
|
||
[source,shell] | ||
---- | ||
$ mvn clean package -Pnative | ||
$ ./target/*-runner | ||
... | ||
[io.quarkus] (main) Quarkus 0.23.2 started in 0.013s. Listening on: http://[::]:8080 | ||
... | ||
---- |
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,99 @@ | ||
<?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/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<groupId>org.apache.camel.quarkus</groupId> | ||
<artifactId>camel-quarkus-build-parent</artifactId> | ||
<version>1.1.0-SNAPSHOT</version> | ||
<relativePath>../../poms/build-parent/pom.xml</relativePath> | ||
</parent> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>camel-quarkus-examples-http-log</artifactId> | ||
<name>Camel Quarkus :: Examples :: HTTP Log</name> | ||
<description>Camel Quarkus Example :: HTTP to Log</description> | ||
|
||
<properties> | ||
<!-- mvnd, a.k.a. Maven Daemon: https://github.com/gnodet/mvnd --> | ||
<!-- The following rule tells mvnd to build the listed deployment modules before this module. --> | ||
<!-- This is important because mvnd builds modules in parallel by default. The deployment modules are not --> | ||
<!-- explicit dependencies of this module in the Maven sense, although they are required by the Quarkus Maven plugin. --> | ||
<!-- Please update rule whenever you change the dependencies of this module by running --> | ||
<!-- mvn process-resources -Pformat from the root directory --> | ||
<mvnd.builder.rule>camel-quarkus-log-deployment,camel-quarkus-support-policy-deployment,camel-quarkus-timer-deployment</mvnd.builder.rule> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-resteasy</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.camel.quarkus</groupId> | ||
<artifactId>camel-quarkus-platform-http</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.camel.quarkus</groupId> | ||
<artifactId>camel-quarkus-log</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.camel.quarkus</groupId> | ||
<artifactId>camel-quarkus-microprofile-health</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.camel.quarkus</groupId> | ||
<artifactId>camel-quarkus-microprofile-metrics</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>build</id> | ||
<goals> | ||
<goal>build</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<profiles> | ||
<profile> | ||
<id>native</id> | ||
<activation> | ||
<property> | ||
<name>native</name> | ||
</property> | ||
</activation> | ||
<properties> | ||
<quarkus.package.type>native</quarkus.package.type> | ||
</properties> | ||
</profile> | ||
</profiles> | ||
|
||
</project> |
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,22 @@ | ||
#!/bin/sh | ||
# | ||
# 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. | ||
# | ||
|
||
# script to aggregate the total RSS memory used by the processes in MB. | ||
# the script includes itself so that adds about 2mb extra in total memory. | ||
# the script is a bit hackish and improvements is welcome. | ||
ps -o rss -o command | grep $1 | awk '{print $1}' | head -n 100 | awk '{sum+=$1/1024}END{print sum}' |
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,29 @@ | ||
#!/bin/sh | ||
# | ||
# 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. | ||
# | ||
|
||
# script to quickly run 100 instances of the native compiled example | ||
# using http port numbers from 8000 - 8100 | ||
# you can then try each instance by its number such as: | ||
# http://localhost:8012/camel/hello | ||
# | ||
# to kill all instances at once, you can use pkill command: | ||
# pkill camel-quarkus | ||
# | ||
for i in $(seq 8000 8100); do | ||
QUARKUS_HTTP_PORT=$i ./target/camel-quarkus-examples-http-log-*-runner > http-log-$i.log & | ||
done |
32 changes: 32 additions & 0 deletions
32
examples/http-log/src/main/java/org/acme/http/CamelRoute.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.acme.http; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
|
||
import org.apache.camel.builder.endpoint.EndpointRouteBuilder; | ||
|
||
@ApplicationScoped | ||
public class CamelRoute extends EndpointRouteBuilder { | ||
|
||
@Override | ||
public void configure() throws Exception { | ||
from(platformHttp("/camel/hello")) | ||
.setBody().simple("Camel runs on ${hostname}") | ||
.to(log("hi").showExchangePattern(false).showBodyType(false)); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
examples/http-log/src/main/java/org/acme/http/ExampleResource.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.acme.http; | ||
|
||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
@Path("/hello") | ||
public class ExampleResource { | ||
|
||
@GET | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public String hello() { | ||
return "hello"; | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
examples/http-log/src/main/resources/application.properties
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,45 @@ | ||
## --------------------------------------------------------------------------- | ||
## 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. | ||
## --------------------------------------------------------------------------- | ||
# | ||
# Quarkus | ||
# | ||
quarkus.log.file.enable = false | ||
quarkus.banner.enabled = false | ||
|
||
# | ||
# Quarkus - Camel | ||
# | ||
|
||
# disable build time route discovery as the only | ||
# route defined in this project is based on CDI. | ||
# | ||
# This is not strictly needed for the correctness | ||
# because camel-quarkus automatically | ||
# filters auto-discovered routes that targets CDI | ||
# but if is is known that routes are all leveraging | ||
# CDI, this option will give some little boost to | ||
# the build process | ||
quarkus.camel.main.routes-discovery.enabled = false | ||
|
||
# bean introspection to log reflection based configuration | ||
camel.main.beanIntrospectionExtendedStatistics=true | ||
camel.main.beanIntrospectionLoggingLevel=INFO | ||
|
||
# | ||
# Camel | ||
# | ||
camel.context.name = quarkus-camel-example-http-log |
Oops, something went wrong.