This guide outlines various ways to create a new Camel Quarkus application.
JDK 11+ with
Apache Maven 3.8.2+ (3.8.4 is recommended)
GraalVM with the
native-imagecommand installed and the
GRAALVM_HOMEenvironment variable set. See Building a native executable section of the Quarkus documentation.
If you are on Linux,
dockeris sufficient for the native mode too. Use
-Pnativeif you choose this option.
Projects can be generated at code.quarkus.io. All of the Camel Quarkus extensions can be found under the 'Integration' category. Use the 'search' field to help with finding extensions that you are interested in.
Simply select the component extensions that you want to work with and click the 'Generate your application' button to download a basic skeleton project. There is also the option to push the project directly to GitHub.
When the project archive download has completed successfully, unzip and import into your favorite IDE.
Quarkus provides a Maven plugin that enables you to quickly bootstrap projects. For example, to create a project skeleton that includes the
log component extensions:
$ mvn io.quarkus:quarkus-maven-plugin:2.7.6.Final:create \ -DprojectGroupId=org.acme \ -DprojectArtifactId=getting-started \ -Dextensions=camel-quarkus-log,camel-quarkus-timer $ cd getting-started
| Windows users should omit the |
Quarkus has plugins for most of the popular development IDEs. They provide Quarkus language support, code / config completion, project creation wizards and much more. The plugins are available at each respective IDE marketplace.
Check the documentation of the given plugin to discover how to create projects in your preferred IDE.
The following plugins provide support for content assist when editing Camel routes and
Apache Camel IDEA plugin (not always up to date)
Camel Quarkus provides a GitHub repository containing a set of example projects.
The main branch is always aligned with the latest Camel Quarkus release.
Clone the Camel Quarkus examples repository:
$ git clone https://github.com/apache/camel-quarkus-examples.git
rest-jsonexample out of the source tree:
$ cp -r camel-quarkus-examples/rest-json . $ cd rest-json
pom.xmlfile in your IDE. Change the project
The application has two compile dependencies:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-platform-http</artifactId> </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-jackson</artifactId> </dependency>
They are managed within the
io.quarkus.platform:quarkus-camel-bom that is imported in
There are only three classes in the application:
Routes defines the Camel routes, whereas
Legume are entities.
The application is configured by properties defined within
src/main/resources/application.properties. E.g. the
camel.context.name is set there.
$ mvn clean compile quarkus:dev
This command compiles the project, starts your 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.
Check the application in the browser, e.g. http://localhost:8080/fruits for the
Then change something in the code and see the changes applied by refreshing the browser.
Please refer to Quarkus documentation for more details about the development mode.
There are two test classes in our example:
RestJsonTest is for the JVM mode while
RestJsonIT is there for the native mode.
The JVM mode tests are run by
maven-surefire-plugin in the
test Maven phase:
$ mvn clean test
This should take about 15 seconds.
The native mode tests are verified by
maven-failsafe-plugin in the
verify phase. Pass the
native property to activate the profile that runs them:
$ mvn clean verify -Pnative
This takes about 2.5 minutes (once you have all dependencies cached).
mvn package prepares a thin
jar for running on a stock JVM:
$ mvn clean package $ ls -lh target/quarkus-app ... -rw-r--r--. 1 ppalaga ppalaga 238K Oct 11 18:55 quarkus-run.jar ...
You can run it as follows:
$ java -jar target/quarkus-app/quarkus-run.jar ... [io.quarkus] (main) Quarkus started in 1.163s. Listening on: http://[::]:8080
Notice the boot time around a second.
jar contains just the application code. To run it, the dependencies in
target/quarkus-app/lib are required too.
To prepare a native executable using GraalVM, run the following command:
$ mvn clean package -Pnative $ ls -lh target ... -rwxr-xr-x. 1 ppalaga ppalaga 46M Oct 11 18:57 my-app-0.0.1-SNAPSHOT-runner ...
Note that the
runner in the listing above has no
.jar extension and has the
x (executable) permission set. Thus it can be run directly:
$ ./target/*-runner ... [io.quarkus] (main) Quarkus started in 0.013s. Listening on: http://[::]:8080 ...
Check how fast it started and check how little memory it consumes:
$ ps -o rss,command -p $(pgrep my-app) RSS COMMAND 34916 ./target/my-app-0.0.1-SNAPSHOT-runner
That’s under 35 MB of RAM!
We recommend to continue with Dependency management.