Routes

A Camel route is where the integration flow is defined. For example to integrate two systems then a Camel route can be coded to specify how these systems are integrated.

An example could be to take files from a FTP server and send to a ActiveMQ messaging system.

This can be coded in a route using Java with the Java DSL

from("ftp:myserver/folder")
  .to("activemq:queue:cheese");

Camel support coding in other languages such as XML:

<route>
  <from uri="ftp:myserver/folder"/>
  <to uri="activemq:queue:cheese"/>
</route>

RouteBuilder with Java DSL

When coding routes with the Java DSL then you would use a RouteBuilder classes where you code the route in the configure method as shown:

RouteBuilder builder = new RouteBuilder() {
    public void configure() {
        from("direct:a").to("direct:b");
    }
};

As you can see from the above Camel uses URIs to wire endpoints together.

Routes using Java lambda style

Camel now supports to define Camel routes in Java DSL using Lambda style. This can be beneficial for microservices or serverless where you may want to quickly define a few routes.

For example using lambda style you can define a Camel route that takes messages from Kafka and send to JMS in a single line of code:

rb -> rb.from("kafka:cheese").to("jms:queue:foo");

There is a bit more to this as the lambda route must be coded in a Java method that returns an instance of LambdaRouteBuilder. See more at the LambdaRouteBuilder documentation.

More Information

See RouteBuilder and DSL for a list of supported languages you can use for coding Camel routes.