Apache camel ApacheCamel-什么时候可以重命名文件?

Apache camel ApacheCamel-什么时候可以重命名文件?,apache-camel,Apache Camel,我发现一个类似这样的示例代码: from("file:/opt/input").multicast().parallelprocessing().to("direct:process-with-bindy","direct:move-to-out").end(); from(“direct:move to out”).setHeader(Exchange.FILE_NAME,simple(使用当前时间重命名))。 到(“文件:/opt/done”).end() 这是否意味着相同的文件将在bin

我发现一个类似这样的示例代码:

from("file:/opt/input").multicast().parallelprocessing().to("direct:process-with-bindy","direct:move-to-out").end();
from(“direct:move to out”).setHeader(Exchange.FILE_NAME,simple(使用当前时间重命名))。
到(“文件:/opt/done”).end()

这是否意味着相同的文件将在bindy处理期间重命名,并且重命名不会影响bindy路由


感谢

这意味着文件将被发送到bindy并同时移出,基本上将执行分为两个线程,它们将同时发生,并且文件不会在bindy处理中重命名(除非它作为“使用bindy处理”的路由的一部分)

解释这与将其发送到一个端点,然后使用第一个端点的结果作为第二个端点的输入有何不同

编辑: 当camel拾取一个文件时,它会从中创建一个交换,bindy正在操纵和处理这个交换。bindy处理线程不知道exchange已被复制,并且正在其他地方作为新文件写入,因此不会发生冲突

测试这一点很容易:

public class FileSplitTest extends CamelTestSupport {

    @Override
    protected RouteBuilder createRouteBuilder() throws Exception {
        return new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                from("file:target/todo")
                        .multicast()
                        .parallelProcessing()
                        .to("direct:process", "direct:file-out").end();

                from("direct:process")
                        .delayer(500)
                        .process(new Processor() {
                            public void process(Exchange exchange) throws Exception {
                                assertTrue("Hello World".equals(exchange.getIn().getBody(String.class)));
                            }
                        })
                        .to("file:target/done");

                from("direct:file-out")
                        .setHeader(Exchange.FILE_NAME, simple("new name"))
                        .to("file:target/done");
            }
        };
    }

    @Override
    public String isMockEndpoints() {
        return "file:target/done";
    }

    @Test
    public void testFileSplit() throws InterruptedException {
        template.sendBodyAndHeader("file:target/todo", "Hello world", Exchange.FILE_NAME, "todo.txt");

        MockEndpoint mockEndpoint = getMockEndpoint("mock:file:target/done");
        mockEndpoint.setExpectedMessageCount(2);

        assertMockEndpointsSatisfied();
    }
}

谢谢你的及时回复。但是,如果使用bindy的进程正在处理该文件,“移动到外部”是否会通过并行重命名同一文件来中断处理?