Skip to content

Commit e9d1bfa

Browse files
authored
Add Variables example
1 parent 1860a34 commit e9d1bfa

File tree

8 files changed

+782
-0
lines changed

8 files changed

+782
-0
lines changed

docs/modules/ROOT/attachments/examples.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,11 @@
139139
"description": "Shows how to produce and consume messages to an aws2-s3 bucket.",
140140
"link": "https://github.com/apache/camel-quarkus-examples/tree/main/aws2-s3"
141141
},
142+
{
143+
"title": "Variables",
144+
"description": "Uses the Camel variables which can be configured from application.properties.",
145+
"link": "https://github.com/apache/camel-quarkus-examples/tree/main/variables"
146+
},
142147
{
143148
"title": "Vertx-Websocket Chat",
144149
"description": "Shows how to configure a WebSocket server and interact with connected peers.",

variables/README.adoc

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
= Variables: A Camel Quarkus example
2+
:cq-example-description: An example that uses the Camel variables which can be configured from application.properties.
3+
4+
{cq-description}
5+
6+
TIP: Check the https://camel.apache.org/camel-quarkus/latest/first-steps.html[Camel Quarkus User guide] for prerequisites
7+
and other general information.
8+
9+
== Start in the Development mode
10+
11+
[source,shell]
12+
----
13+
$ mvn clean compile quarkus:dev
14+
----
15+
16+
The above command compiles the project, starts the application and lets the Quarkus tooling watch for changes in your
17+
workspace. Any modifications in your project will automatically take effect in the running application.
18+
19+
TIP: Please refer to the Development mode section of
20+
https://camel.apache.org/camel-quarkus/latest/first-steps.html#_development_mode[Camel Quarkus User guide] for more details.
21+
22+
Then look at the log output in the console. There are log messages generated from a second route. First several message show random number `N/A` (as is defined in application.properties). Following messages show random number generated by the first route, which starts delayed.
23+
24+
As we run the example in Quarkus Dev Mode, you can edit the source code and have live updates.
25+
For example, try to change the default greeting message in `application.properties` to `Greeting`.
26+
27+
The delay of the random member generation and period at which the timer fires can be changed by modifying configuration properties `timer.period` and
28+
`timer.delay` in `application.properties`. You can also override the default values via the command line with JVM arguments
29+
`-Dtimer.period=100 -Dtimer.delay=1000'
30+
31+
=== Package and run the application
32+
33+
Once you are done with developing you may want to package and run the application.
34+
35+
TIP: Find more details about the JVM mode and Native mode in the Package and run section of
36+
https://camel.apache.org/camel-quarkus/latest/first-steps.html#_package_and_run_the_application[Camel Quarkus User guide]
37+
38+
==== JVM mode
39+
40+
[source,shell]
41+
----
42+
$ mvn clean package
43+
$ java -jar target/quarkus-app/quarkus-run.jar
44+
...
45+
[io.quarkus] (main) camel-quarkus-examples-... started in 1.163s.
46+
----
47+
48+
==== Native mode
49+
50+
IMPORTANT: Native mode requires having GraalVM and other tools installed. Please check the Prerequisites section
51+
of https://camel.apache.org/camel-quarkus/latest/first-steps.html#_prerequisites[Camel Quarkus User guide].
52+
53+
To prepare a native executable using GraalVM, run the following command:
54+
55+
[source,shell]
56+
----
57+
$ mvn clean package -Pnative
58+
$ ./target/*-runner
59+
...
60+
[io.quarkus] (main) camel-quarkus-examples-... started in 0.013s.
61+
...
62+
----
63+
64+
== Feedback
65+
66+
Please report bugs and propose improvements via https://github.com/apache/camel-quarkus/issues[GitHub issues of Camel Quarkus] project.

variables/eclipse-formatter-config.xml

Lines changed: 276 additions & 0 deletions
Large diffs are not rendered by default.

variables/pom.xml

Lines changed: 289 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,289 @@
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/xsd/maven-4.0.0.xsd">
21+
<modelVersion>4.0.0</modelVersion>
22+
23+
<artifactId>camel-quarkus-examples-variables</artifactId>
24+
<groupId>org.apache.camel.quarkus.examples</groupId>
25+
<version>3.31.0-SNAPSHOT</version>
26+
27+
<name>Camel Quarkus :: Examples :: Variables</name>
28+
<description>Camel Quarkus Example :: Variables</description>
29+
30+
<properties>
31+
<quarkus.platform.version>3.30.1</quarkus.platform.version>
32+
<camel-quarkus.platform.version>3.31.0-SNAPSHOT</camel-quarkus.platform.version>
33+
34+
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
35+
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
36+
<camel-quarkus.platform.group-id>org.apache.camel.quarkus</camel-quarkus.platform.group-id>
37+
<camel-quarkus.platform.artifact-id>camel-quarkus-bom</camel-quarkus.platform.artifact-id>
38+
39+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
40+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
41+
<maven.compiler.release>17</maven.compiler.release>
42+
43+
<formatter-maven-plugin.version>2.29.0</formatter-maven-plugin.version>
44+
<impsort-maven-plugin.version>1.12.0</impsort-maven-plugin.version>
45+
<license-maven-plugin.version>5.0.0</license-maven-plugin.version>
46+
<maven-compiler-plugin.version>3.14.1</maven-compiler-plugin.version>
47+
<maven-jar-plugin.version>3.5.0</maven-jar-plugin.version>
48+
<maven-resources-plugin.version>3.3.1</maven-resources-plugin.version>
49+
<maven-surefire-plugin.version>3.5.4</maven-surefire-plugin.version>
50+
</properties>
51+
52+
<dependencyManagement>
53+
<dependencies>
54+
<!-- Import BOM -->
55+
<dependency>
56+
<groupId>${quarkus.platform.group-id}</groupId>
57+
<artifactId>${quarkus.platform.artifact-id}</artifactId>
58+
<version>${quarkus.platform.version}</version>
59+
<type>pom</type>
60+
<scope>import</scope>
61+
</dependency>
62+
<dependency>
63+
<groupId>${camel-quarkus.platform.group-id}</groupId>
64+
<artifactId>${camel-quarkus.platform.artifact-id}</artifactId>
65+
<version>${camel-quarkus.platform.version}</version>
66+
<type>pom</type>
67+
<scope>import</scope>
68+
</dependency>
69+
</dependencies>
70+
</dependencyManagement>
71+
72+
<dependencies>
73+
<dependency>
74+
<groupId>org.apache.camel.quarkus</groupId>
75+
<artifactId>camel-quarkus-log</artifactId>
76+
</dependency>
77+
<dependency>
78+
<groupId>org.apache.camel.quarkus</groupId>
79+
<artifactId>camel-quarkus-timer</artifactId>
80+
</dependency>
81+
82+
<!-- Test -->
83+
<dependency>
84+
<groupId>io.quarkus</groupId>
85+
<artifactId>quarkus-junit5</artifactId>
86+
<scope>test</scope>
87+
</dependency>
88+
<dependency>
89+
<groupId>org.awaitility</groupId>
90+
<artifactId>awaitility</artifactId>
91+
<scope>test</scope>
92+
</dependency>
93+
</dependencies>
94+
95+
<build>
96+
<pluginManagement>
97+
<plugins>
98+
99+
<plugin>
100+
<groupId>net.revelc.code.formatter</groupId>
101+
<artifactId>formatter-maven-plugin</artifactId>
102+
<version>${formatter-maven-plugin.version}</version>
103+
<configuration>
104+
<configFile>${maven.multiModuleProjectDirectory}/eclipse-formatter-config.xml</configFile>
105+
<lineEnding>LF</lineEnding>
106+
</configuration>
107+
</plugin>
108+
109+
<plugin>
110+
<groupId>net.revelc.code</groupId>
111+
<artifactId>impsort-maven-plugin</artifactId>
112+
<version>${impsort-maven-plugin.version}</version>
113+
<configuration>
114+
<groups>java.,javax.,org.w3c.,org.xml.,junit.</groups>
115+
<removeUnused>true</removeUnused>
116+
<staticAfter>true</staticAfter>
117+
<staticGroups>java.,javax.,org.w3c.,org.xml.,junit.</staticGroups>
118+
</configuration>
119+
</plugin>
120+
121+
<plugin>
122+
<groupId>org.apache.maven.plugins</groupId>
123+
<artifactId>maven-compiler-plugin</artifactId>
124+
<version>${maven-compiler-plugin.version}</version>
125+
<configuration>
126+
<showDeprecation>true</showDeprecation>
127+
<showWarnings>true</showWarnings>
128+
<compilerArgs>
129+
<arg>-Xlint:unchecked</arg>
130+
</compilerArgs>
131+
</configuration>
132+
</plugin>
133+
134+
<plugin>
135+
<groupId>org.apache.maven.plugins</groupId>
136+
<artifactId>maven-surefire-plugin</artifactId>
137+
<version>${maven-surefire-plugin.version}</version>
138+
<configuration>
139+
<failIfNoTests>false</failIfNoTests>
140+
<systemPropertyVariables>
141+
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
142+
</systemPropertyVariables>
143+
</configuration>
144+
</plugin>
145+
146+
<plugin>
147+
<groupId>${quarkus.platform.group-id}</groupId>
148+
<artifactId>quarkus-maven-plugin</artifactId>
149+
<version>${quarkus.platform.version}</version>
150+
<extensions>true</extensions>
151+
</plugin>
152+
153+
<plugin>
154+
<groupId>org.apache.maven.plugins</groupId>
155+
<artifactId>maven-failsafe-plugin</artifactId>
156+
<version>${maven-surefire-plugin.version}</version>
157+
</plugin>
158+
159+
<plugin>
160+
<groupId>org.apache.maven.plugins</groupId>
161+
<artifactId>maven-jar-plugin</artifactId>
162+
<version>${maven-jar-plugin.version}</version>
163+
</plugin>
164+
165+
<plugin>
166+
<groupId>com.mycila</groupId>
167+
<artifactId>license-maven-plugin</artifactId>
168+
<version>${license-maven-plugin.version}</version>
169+
<configuration>
170+
<failIfUnknown>true</failIfUnknown>
171+
<header>${maven.multiModuleProjectDirectory}/header.txt</header>
172+
<excludes>
173+
<exclude>**/*.adoc</exclude>
174+
<exclude>**/*.txt</exclude>
175+
<exclude>**/LICENSE.txt</exclude>
176+
<exclude>**/LICENSE</exclude>
177+
<exclude>**/NOTICE.txt</exclude>
178+
<exclude>**/NOTICE</exclude>
179+
<exclude>**/README</exclude>
180+
<exclude>**/pom.xml.versionsBackup</exclude>
181+
<exclude>**/quarkus.log*</exclude>
182+
</excludes>
183+
<mapping>
184+
<java>SLASHSTAR_STYLE</java>
185+
<properties>CAMEL_PROPERTIES_STYLE</properties>
186+
<kt>SLASHSTAR_STYLE</kt>
187+
</mapping>
188+
<headerDefinitions>
189+
<headerDefinition>${maven.multiModuleProjectDirectory}/license-properties-headerdefinition.xml</headerDefinition>
190+
</headerDefinitions>
191+
</configuration>
192+
</plugin>
193+
</plugins>
194+
</pluginManagement>
195+
196+
<plugins>
197+
<plugin>
198+
<groupId>${quarkus.platform.group-id}</groupId>
199+
<artifactId>quarkus-maven-plugin</artifactId>
200+
<executions>
201+
<execution>
202+
<id>build</id>
203+
<goals>
204+
<goal>build</goal>
205+
</goals>
206+
</execution>
207+
</executions>
208+
</plugin>
209+
210+
<plugin>
211+
<groupId>net.revelc.code.formatter</groupId>
212+
<artifactId>formatter-maven-plugin</artifactId>
213+
<executions>
214+
<execution>
215+
<id>format</id>
216+
<goals>
217+
<goal>format</goal>
218+
</goals>
219+
<phase>process-sources</phase>
220+
</execution>
221+
</executions>
222+
</plugin>
223+
224+
<plugin>
225+
<groupId>net.revelc.code</groupId>
226+
<artifactId>impsort-maven-plugin</artifactId>
227+
<executions>
228+
<execution>
229+
<id>sort-imports</id>
230+
<goals>
231+
<goal>sort</goal>
232+
</goals>
233+
<phase>process-sources</phase>
234+
</execution>
235+
</executions>
236+
</plugin>
237+
238+
<plugin>
239+
<groupId>com.mycila</groupId>
240+
<artifactId>license-maven-plugin</artifactId>
241+
<executions>
242+
<execution>
243+
<id>license-format</id>
244+
<goals>
245+
<goal>format</goal>
246+
</goals>
247+
<phase>process-sources</phase>
248+
</execution>
249+
</executions>
250+
</plugin>
251+
</plugins>
252+
</build>
253+
254+
<profiles>
255+
<profile>
256+
<id>native</id>
257+
<activation>
258+
<property>
259+
<name>native</name>
260+
</property>
261+
</activation>
262+
<properties>
263+
<quarkus.native.enabled>true</quarkus.native.enabled>
264+
</properties>
265+
<build>
266+
<plugins>
267+
<plugin>
268+
<groupId>org.apache.maven.plugins</groupId>
269+
<artifactId>maven-failsafe-plugin</artifactId>
270+
<executions>
271+
<execution>
272+
<goals>
273+
<goal>integration-test</goal>
274+
<goal>verify</goal>
275+
</goals>
276+
<configuration>
277+
<systemPropertyVariables>
278+
<quarkus.native.enabled>${quarkus.native.enabled}</quarkus.native.enabled>
279+
</systemPropertyVariables>
280+
</configuration>
281+
</execution>
282+
</executions>
283+
</plugin>
284+
</plugins>
285+
</build>
286+
</profile>
287+
</profiles>
288+
289+
</project>

0 commit comments

Comments
 (0)