forked from apache/camel-quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support Quarkus command mode apache#1037
- Loading branch information
1 parent
1f040b5
commit 62b1801
Showing
22 changed files
with
507 additions
and
79 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
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,56 @@ | ||
= timer-log | ||
|
||
This is a basic hello world example that uses a cusomt main to set-up | ||
a Camel timer that triggers every second and prints to the log. | ||
|
||
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 | ||
---- | ||
|
||
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. | ||
|
||
Then look at the log output in the console. As we run the example in Quarkus Dev Mode, you can edit the source code and have live updates. | ||
For example try to change `Incremented the counter` to `Counter state` in the message body or change the property `timer.period` in application.properties | ||
|
||
=== 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 1.3.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 1.3.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,90 @@ | ||
<?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-timer-log-main</artifactId> | ||
<name>Camel Quarkus :: Examples :: Timer Log Main</name> | ||
<description>Camel Quarkus Example :: Timer to Log Main</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>org.apache.camel.quarkus</groupId> | ||
<artifactId>camel-quarkus-main</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.camel.quarkus</groupId> | ||
<artifactId>camel-quarkus-timer</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.camel.quarkus</groupId> | ||
<artifactId>camel-quarkus-log</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> |
28 changes: 28 additions & 0 deletions
28
examples/timer-log-main/src/main/java/org/acme/timer/Main.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,28 @@ | ||
/* | ||
* 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.timer; | ||
|
||
import io.quarkus.runtime.Quarkus; | ||
import io.quarkus.runtime.annotations.QuarkusMain; | ||
import org.apache.camel.quarkus.main.CamelMainApplication; | ||
|
||
@QuarkusMain | ||
public class Main { | ||
public static void main(String... args) { | ||
Quarkus.run(CamelMainApplication.class, args); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
examples/timer-log-main/src/main/java/org/acme/timer/TimerRoute.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,34 @@ | ||
/* | ||
* 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.timer; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
|
||
import org.apache.camel.builder.RouteBuilder; | ||
|
||
/** | ||
* A simple {@link RouteBuilder}. | ||
*/ | ||
@ApplicationScoped | ||
public class TimerRoute extends RouteBuilder { | ||
@Override | ||
public void configure() throws Exception { | ||
from("timer:foo?period={{timer.period}}") | ||
.setBody().constant("Hello from Main!") | ||
.to("log:example"); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
examples/timer-log-main/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,42 @@ | ||
## --------------------------------------------------------------------------- | ||
## 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.banner.enabled = false | ||
|
||
# camel look-up beans using BeanManager so we don't want | ||
# ArC to remove beans without injection points. | ||
quarkus.arc.remove-unused-beans = false | ||
|
||
# | ||
# Camel - Main | ||
# | ||
camel.main.duration-hit-exit-code = 15 | ||
|
||
# | ||
# Camel - Components | ||
# | ||
camel.component.log.exchange-formatter = #class:org.apache.camel.support.processor.DefaultExchangeFormatter | ||
camel.component.log.exchange-formatter.show-exchange-pattern = false | ||
camel.component.log.exchange-formatter.show-body-type = false | ||
|
||
# | ||
# Integration | ||
# | ||
timer.period = 5000 |
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
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
Oops, something went wrong.