我有一个平面文件,其中每一行都需要被捕获并解组为POJO. 我正在使用Camel和Bindy使用Splitter EIP. 由于某种原因,我无法在解组完成后检查POJO(使用 a )。Processor有什么建议么?
我正在尝试在下面的两次转换之后调试右侧的Exchange内部。代码永远不会被调用(断点永远不会到达)ProcessBindy
这是我的代码:
from("file://inbox")
.setHeader(Exchange.FILE_NAME,simple("${file:name.noext}-${date:now:yyyyMMddHHmmssSSS}.${file:ext}"))
.wireTap("file://ORIGINAL_BACKUP")
.process(converterProcessor)
.split(body(String.class).tokenize(System.lineSeparator()))
.choice()
.when(new Predicate() {
public boolean matches(Exchange exchange) {
if(exchange.getIn().getBody().toString().startsWith("HEADER1")) return true;
return false;
}
})
.unmarshal()
.bindy(BindyType.Fixed, MessageHeaderGroup_HEADER1.class).process(new Processor() {
public void process(Exchange exchange) throws Exception {
System.out.println("Object: "+ exchange.getIn().getBody());
}
}).to("direct:mhg")
.when(new Predicate() {
public boolean matches(Exchange exchange) {
if(exchange.getIn().getBody().toString().startsWith("HEADER2")) return true;
return false;
}
})
.unmarshal()
.bindy(BindyType.Fixed, TransactionHeaderGroup_HEADER2.class).process(new Processor() {
public void process(Exchange exchange) throws Exception {
System.out.println("Object: "+ exchange.getIn().getBody());
}
}).to("direct:trg")
.otherwise().to("file://outbox");
我对Camel. 我试图结束choice()使用endChoice(),但无济于事。如果我使用 a Filter EIP(仅使用一种可能的Bindy转换),我可以Exchange在Process步骤中检查。但是,如果我切换到choice()withPredicate我就无法做到。感谢您的建议!