- Apache Camel Developer's Cookbook
- Scott Cranton Jakub Korab
- 218字
- 2021-07-19 18:46:31
The Camel DSL
All integration routes are defined in Camel through its own domain-specific language (DSL). This book presents the two main DSL flavors when discussing routing, the Java DSL, and the Spring XML DSL. OSGi Blueprint XML DSL is modeled after Spring, and is touched on lightly in this book. The Spring and OSGi Blueprint XML DSLs are collectively referred to as the XML DSL). There are other DSL variants available for defining Camel routes, including Groovy and Scala. For details on these see the following links:
- Groovy DSL: http://camel.apache.org/groovy-dsl.html
- Scala DSL: http://camel.apache.org/scala-dsl.html
Here is an example of a classic Content Based Router configured in Camel using both the XML and Java DSLs. You can find out more details on this in the Content Based Router recipe in Chapter 2, Message Routing.
In the XML DSL, you would write the routing logic as:
<route> <from uri="direct:start"/> <choice> <when> <simple>${body} contains 'Camel'</simple> <log message="Camel ${body}"/> </when> <otherwise> <log message="Other ${body}"/> </otherwise> </choice> <log message="Message ${body}"/> </route>
In the Java DSL, the same route is expressed as:
from("direct:start") .choice() .when().simple("${body} contains 'Camel'") .log("Camel ${body}") .otherwise() .log("Other ${body}") .end() .log("Message ${body}");
The decision of which flavor of DSL to use is largely a personal one, and using one does not rule out using another alongside it. There are pros and cons to each, though none are functional. All of the DSL variants allow you to fully use Camel's features.

- 零基礎搭建量化投資系統:以Python為工具
- LabVIEW入門與實戰開發100例
- Dependency Injection in .NET Core 2.0
- RTC程序設計:實時音視頻權威指南
- Expert Android Programming
- SAS數據統計分析與編程實踐
- Mastering RStudio:Develop,Communicate,and Collaborate with R
- 深入分布式緩存:從原理到實踐
- Android應用案例開發大全(第二版)
- Arduino Wearable Projects
- 深入淺出Python數據分析
- 現代CPU性能分析與優化
- Go Systems Programming
- Learning Alfresco Web Scripts
- Distributed Computing with Python