猿问

Apache 骆驼:停止交换进行 delete=true

我只想允许从源目录中删除非重复文件。我有一条这样的幂等消费者的路线:


File repo = new File("repo.txt");

IdempotentRepository fr = FileIdempotentRepository.fileIdempotentRepository(repo);


from("sftp:someServer:somePort/someDir?delete=true")

    .idempotentConsumer(header("CamelFileName"),fr)

    .to("file:output");

在这种情况下,delete=true 将导致从源目录中删除重复消息的路由。为了防止这种情况,我尝试了以下代码:


File repo = new File("repo.txt");

IdempotentRepository fr = FileIdempotentRepository.fileIdempotentRepository(repo);


from("sftp:someServer:somePort/someDir?delete=true")

    .idempotentConsumer(header("CamelFileName"),fr)

    .skipDuplicate(false)

    .filter(exchangeProperty(Exchange.DUPLICATE_MESSAGE).isEqualTo(true))

        .process(new Processor() {

            @Override

            public void process(Exchange exchange) throws Exception {

                exchange.setException(new InterruptedException("Cancel Exchange"));

                exchange.setProperty(Exchange.ROUTE_STOP, Boolean.TRUE);

            }

         })

    .end()

.to("file:output");

由于从路由内的 sftp 删除将需要另一个 jsch 实例,因此我希望能够使用 sftp 使用者的删除属性


慕婉清6462132
浏览 211回答 1
1回答
随时随地看视频慕课网APP

相关分类

Java
我要回答