LibraryLink ToToggle FramesPrintFeedback

Implementing a RouteBuilder Class

To use the Domain Specific Language (DSL), you extend the RouteBuilder class and override its configure() method; in this method 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. To do this, you extend the org.apache.camel.builder.RouteBuilder base class and override its abstract method, configure().

The RouteBuilder class defines methods used to initiate your routing rules (for example, from(), intercept(), and exception()).

Example 2.1 shows a minimal RouteBuilder implementation. The configure() method body contains a routing rule; each rule is a single Java statement.

The form of the rule from(URL1).to(URL2) instructs the router to read files from the directory 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.