Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.Ce contenu n'est pas disponible dans la langue sélectionnée.
Chapter 1. Building Blocks for Route Definitions
Abstract
						Apache Camel supports two alternative Domain Specific Languages (DSL) for defining routes: a Java DSL and a Spring XML DSL. The basic building blocks for defining routes are endpoints and processors, where the behavior of a processor is typically modified by expressions or logical predicates. Apache Camel enables you to define expressions and predicates using a variety of different languages.
					
1.1. Implementing a RouteBuilder Class
Copier lienLien copié sur presse-papiers!
Overview
Copier lienLien copié sur presse-papiers!
					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.
				RouteBuilder classes
Copier lienLien copié sur presse-papiers!
					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 generic- RouteBuilderbase class that is suitable for deploying into any container type. It is provided in the- camel-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 the- beanRef()Java DSL command) and transactions (see the Transactions Guide for details). It is provided in the- camel-springartifact.
					The 
RouteBuilder class defines methods used to initiate your routing rules (for example, from(), intercept(), and exception()).
				Implementing a RouteBuilder
Copier lienLien copié sur presse-papiers!
					Example 1.1, “Implementation of a RouteBuilder Class” 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
					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.