Camel Maven Plugin (Dev Guides)
The Camel Maven Plugin will support the following goals:
camel:run - To run your Camel application
camel:dev - To run your Camel application in developer mode
camel:prepare-fatjar - To prepare your Camel application for being packaged as a fat-jar (such as by maven-assembly-plugin)
camel:run
The goal of the Camel Maven Plugin is used to run your Camel Spring configurations in a forked JVM from Maven. A good example application to get you started is the Spring Example:
cd examples/camel-example-spring
mvn camel:run
This approach makes it easy to start and test your routing rules without the added aspect of having to write a main(…​) method. Additionally, it also lets you create multiple jars to host different sets of routing rules and easily test them independently.
The Camel Maven plugin compiles the source code in the Maven project, then boots up a Spring ApplicationContext using the XML configuration files on the classpath at META-INF/spring/*.xml
camel:run Options
The plugin run goal supports the following options which can be configured from the command line (use -D
syntax), or defined in the pom.xml
file in the <configuration>
tag.
Parameter | Default Value | Description |
---|---|---|
duration | -1 | Sets the time duration (seconds) that the application runs for before terminating. NOTE: A value = 0 will run forever. |
durationIdle | -1 | Sets the idle time duration (seconds) duration that the application can be idle for before terminating. NOTE: A value = 0 will run forever. |
durationMaxMessages | -1 | Sets the duration of maximum number of messages that the application processes before terminating. |
logClasspath | false | Boolean on whether to log the classpath when starting |
camel:validate
For validating the source code for misconfigured Camel: * endpoint URIs * simple expressions or predicates * duplicate route ids. We can run the camel:validate
goal from the command line or from within your Java editor such as IDEA or Eclipse.
mvn camel:validate
Or, enable the plugin to automatic run as part of the build to catch these errors:
<plugin>
<groupId>....</groupId>
<artifactId>camel-maven-plugin</artifactId>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>validate</goal>
</goals>
</execution>
</executions>
</plugin>
Â
Run camel:validate on Maven Project
We are also able to run the validate goal on any Maven project without having to add the plugin to the pom.xml
file. However, doing so requires specifying the plugin using its fully qualified name. For example:
Which would return the following:
camel:validate Options
The Camel Maven plugin validate goal supports the following options which can be configured from the command line (use -D
syntax), or defined in the pom.xml
file in the <configuration>
tag.
Parameter | Default | Description |
---|---|---|
downloadVersion | true | Boolean value on whether to allow downloading Camel catalog version from the internet. |
failOnError | false | Boolean value on whether to fail if invalid Camel endpoints were found |
includeJava | true | Boolean on whether to include Java files to be validated for invalid Camel endpoint |
includeXML | true | Boolean on whether to include XML files to be validated for invalid Camel endpoints |
includeTest | false | Boolean on whether to include test source code |
includes | Â | To filter the names of java and xml files to only include files matching any of the given list of pattern |
excludes | Â | To filter the names of java and xml files to only exclude files matching any of the given list of pattern |
duplicateRouteId | true | Boolean value on whether to validate for duplicate route ids. Route ids should be unique |
showAll | false | Boolean on whether to show all endpoints and simple expressions (both invalid and valid). |
directOrSedaPairCheck | true | Boolean on whether to validate direct/seda endpoints sending to non existing consumer |