To use the Domain Specific Language (DSL), you extend the
RouteBuilder class and override its configure()
method (where you define your routing rules).
You can define as many RouteBuilder classes as necessary. Each class
is instantiated once and is registered with the CamelContext object.
Normally, the lifecycle of each RouteBuilder object is managed
automatically by the container in which you deploy the router.
As a router developer, your core task is to implement one or more
RouteBuilder classes. There are two alternative
RouteBuilder classes that you can inherit from:
org.apache.camel.builder.RouteBuilder—this is the genericRouteBuilderbase class that is suitable for deploying into any container type. It is provided in thecamel-coreartifact.org.apache.camel.spring.SpringRouteBuilder—this base class is specially adapted to the Spring container. In particular, it provides extra support for the following Spring specific features: looking up beans in the Spring registry (using thebeanRef()Java DSL command) and transactions (see the Transactions Guide for details). It is provided in thecamel-springartifact.
The RouteBuilder class defines methods used to initiate your routing
rules (for example, from(), intercept(), and
exception()).
Example 1.1 shows a minimal RouteBuilder
implementation. The configure() method body contains a routing rule; each
rule is a single Java statement.
Example 1.1. Implementation of a RouteBuilder Class
import org.apache.camel.builder.RouteBuilder; public class MyRouteBuilder extends RouteBuilder { public void configure() { // Define routing rules here: from("file:src/data?noop=true").to("file:target/messages"); // More rules can be included, in you like. // ... } }
The form of the rule
from(
instructs the router to read files from the directory URL1).to(URL2)src/data and send them to the directory target/messages. The option ?noop=true instructs the router
to retain (not delete) the source files in the src/data directory.








