Apache Camel读/写输入流/来自输入流

时间:2018-05-09 18:35:04

标签: java apache-camel

我目前正在尝试使用Apache Camel来解密已加载到InputStream中的PGP加密文件。我面临的当前问题是CamelContext在启动后似乎挂起,好像它在耗尽流后不断从direct:is读取。我跟着Apache Camel - how to use InputStream as source?到达了可能将给定的InputStream加载到输入通道的点。

    CamelContext context = new DefaultCamelContext();
    CountDownLatch latch = new CountDownLatch(1);

    context.addRoutes(new RouteBuilder() {
        public void configure() {
            from("direct:is")
                    .unmarshal().pgp(secretKeyFileName, keyUserId, keyPassword)
                    .to("direct:os")
                    .process(exchange -> latch.countDown());
        }
    });

    DefaultFluentProducerTemplate.on(context).withBody(inputStream).to("direct:is");
    DefaultFluentProducerTemplate.on(context).withBody(outputStream);
    context.start();
    latch.await();
    context.stop();

0 个答案:

没有答案