Java DSL
Camel uses a Java Domain Specific Language or DSL for creating Enterprise Integration Patterns or Routes. The benefits of using a Java DSL is that your IDE can smart complete your code as you start typing, rather than having to mess around with buckets of XML. The Java DSL is also very expressive as you can mix and match your own code within the language for Expression or Predicate evaluations or easily add a custom Processor.
The main entry points for the DSL are
- CamelContext for creating a Camel routing rulebase
- RouteBuilder for creating a collection of routes using the routing DSL
Handling errors
You can handle errors in a number of ways such as
- by specifying an Error Handler
- using the Exception Clause via the exception() method
Using Interceptors
You can register interceptors on a RouteBuilder so that they are inherited by all child routes. You can also use the DSL itself to write interceptors...
// lets log all steps in all routes interept().to("log:foo"); from("seda:foo").to("seda:bar");
You can also add a predicate to the intercept() method so that your interceptor will only be invoked if the predicate is true.
// lets log messages from gold customers interept(xpath("/customer[@type='gold']).to("log:customer"); from("seda:foo").to("seda:bar");
See Also
For more examples of the DSL in action see