我一直在尝试建立一个简单的程序来读取文件并使用Apache Camel写入一个单独的文件,并且在仔细研究了如何阅读文档之后,我提出了以下建议
public static void main(String[] argv) {
CamelContext context = new DefaultCamelContext();
RouteBuilder route = new RouteBuilder() {
@Override
public void configure() throws Exception {
from("file:/home/user/?fileName=temp.txt&charset=UTF-8&noop=true")
.to("/home/user/?fileName=tempOut.txt&charset=UTF-8");
}
}
context.addRoutes(route);
context.start();
context.stop();
}
控制台输出如下
[main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.11.1 (CamelContext: camel-1) is starting
[main] INFO org.apache.camel.management.ManagementStrategyFactory - JMX enabled.
[main] INFO org.apache.camel.impl.converter.DefaultTypeConverter - Loaded 172 type converters
[main] INFO org.apache.camel.component.file.FileEndpoint - Endpoint is configured with noop=true so forcing endpoint to be idempotent as well
[main] INFO org.apache.camel.component.file.FileEndpoint - Using default memory based idempotent repository with cache max size: 1000
[main] INFO org.apache.camel.impl.DefaultCamelContext - Route: route1 started and consuming from: Endpoint[file:///home/justin/?charset=utf-8&fileName=temp1.txt&noop=true]
[main] INFO org.apache.camel.management.DefaultManagementLifecycleStrategy - Load performance statistics enabled.
[main] INFO org.apache.camel.impl.DefaultCamelContext - Total 1 routes, of which 1 is started.
[main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.11.1 (CamelContext: camel-1) started in 0.680 seconds
[main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.11.1 (CamelContext: camel-1) is shutting down
[main] INFO org.apache.camel.impl.DefaultShutdownStrategy - Starting to graceful shutdown 1 routes (timeout 300 seconds)
但是tempOut.txt,我在磁盘上的任何位置(至少对我来说这是没有道理的)都没有得到结果。我的问题是为什么呢?我也注意到控制台输出中显示“...consuming from: Endpoint[file:///home/...多余/的来自哪里,因为我在文件路径中没有它们?
红颜莎娜
相关分类