camel笔记

来源:互联网 发布:淘宝商城靴子 编辑:程序博客网 时间:2024/06/06 00:12

camel是一个开源的集成框架,它的核心特征是它的路由和中介引擎。而它有两种方式去定义路由的规则:

1.基于java特定域的DSL 语言

2.Spring Xml配置的方式。

Java  DSL :from("file:data/inbox").to("jms:queue:order");


Spring  DSL:<route>
                    <from uri="file:data/inbox"/>
                    <to uri="jms:queue:order"/>
                    </route>



public class FileCopierWithCamel {
public static void main(String args[]) throws Exception {
CamelContext context = new DefaultCamelContext();
context.addRoutes(new RouteBuilder() {
public void configure() {
from("file:data/inbox?noop=true")
.to("file:data/outbox");
}
});
context.start();
Thread.sleep(10000);
context.stop();
}
}


noop选项告诉camel把源文件保留。如果你不使用这个选项,文件会被删除。




0 0