Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The camel:run 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.

Code Block

cd examples/camel-example-spring
mvn camel:run

...

How this works is that the plugin will compile the source code in the maven project, then boot up a Spring ApplicationContext using the XML confiuration files on the classpath at

Code Block

META-INF/spring/*.xml

If you want to boot up your Camel routes a little faster, you could try the camel:embedded instead.

...

From Camel 2.10 onwards the camel:run plugin also supports running a Blueprint application, and by default it scans for OSGi blueprint files in

Code Block

OSGI-INF/blueprint/*.xml

You would need to configure the camel:run plugin to use blueprint, by setting useBlueprint to true as shown below

Code Block
xml
xml

      <plugin>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-maven-plugin</artifactId>
        <configuration>
          <useBlueprint>true</useBlueprint>
        </configuration>
      </plugin>    

...

You can use the applicationContextUri configuration to specify an explicit blueprint XML file, such as:

Code Block
xml
xml

      <plugin>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-maven-plugin</artifactId>
        <configuration>
          <useBlueprint>true</useBlueprint>
          <applicationContextUri>myBlueprint.xml</applicationContextUri>
          <!-- ConfigAdmin options which have been added since Camel 2.12.0 -->
          <configAdminPid>test</configAdminPid>
          <configAdminFileName>/user/test/etc/test.cfg</configAdminFileName>
        </configuration>
      </plugin>    

...

You would need to configure the camel:run plugin to use CDI, by setting useCDI to true as shown below

Code Block
xml
xml

      <plugin>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-maven-plugin</artifactId>
        <configuration>
          <useCDI>true</useCDI>
        </configuration>
      </plugin>    

...

From the source of Camel you can run a CDI example via

Code Block

cd examples/camel-example-cdi
mvn compile camel:run

About DOT generation

camel:run will by default try to run dot generation to generate Visualisation diagrams.
This feature could in some rare cases cause the application to hang, so its by default disabled in Camel 1.6.1 or newer.

...

Code Block
xmlxml

      <plugin>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-maven-plugin</artifactId>
        <configuration>
          <useDot>true</useDot>
        </configuration>
      </plugin>    

Logging the classpath

From Camel 2.10 onwards you can configure whether the classpath should be logged when camel:run executes. In older releases the classpath is always logged.
This can be verbose and noisy, so from Camel 2.10 onwards, the classpath is not logged anymore. You can enable this in the configuration using:

Code Block
xml
xml

      <plugin>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-maven-plugin</artifactId>
        <configuration>
          <logClasspath>true</logClasspath>
        </configuration>
      </plugin>