我目前正在尝试使用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();