apache came 初识
-
简介
Camel框架的核心是一个路由引擎,或者更确切地说是一个路由引擎构建器。它允许您定义自己的路由规则,决定从哪个源接收消息,并确定如何处理这些消息并将其发送到其他目标。
参考:https://www.jianshu.com/p/68aba8d09a89 -
实践
file to file
pom:
<java.version>1.8</java.version>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
test类:
package com.example.cameldemo.test;
import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
/**
-
@Classname Test
*/
public class Test {
public static void main(String[] args) throws Exception {
CamelContext contest = new DefaultCamelContext();
contest.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("file:data/in?noop=true")
.to("file:data/out");
}
});
contest.start();;
Thread.sleep(10000);contest.stop();
}
}