Java 驼峰聚合策略错误的结果

Java 驼峰聚合策略错误的结果,java,apache-camel,Java,Apache Camel,我使用CAMEL聚合来自两个源的响应,一个是xml,另一个是json。最初,我已经将这些回复截短,并从文件中获取它们。 目标是汇总两个来源的响应 我的聚合器路径如下所示 from("direct:fetchProfile") .multicast(new ProfileAggregationStrategy()).stopOnException() .enrich("direct:xmlProfile") .enrich("direct:jsonProfile")

我使用CAMEL聚合来自两个源的响应,一个是xml,另一个是json。最初,我已经将这些回复截短,并从文件中获取它们。 目标是汇总两个来源的响应

我的聚合器路径如下所示

    from("direct:fetchProfile")
    .multicast(new ProfileAggregationStrategy()).stopOnException()
    .enrich("direct:xmlProfile")
    .enrich("direct:jsonProfile")
    .end();
我的“direct:xmlProfile”路由看起来像-

    from("direct:xmlProfile")
    .process(new Processor(){

    @Override
        public void process(Exchange exchange) throws Exception {
            String filename = "target/classes/xml/customerDetails.xml";
             InputStream fileStream = new FileInputStream(filename);
            exchange.getIn().setBody(fileStream);
         }
     })
    .split(body().tokenizeXML("attributes", null))
    .unmarshal(jaxbDataFormat)
    .process(new Processor(){
        @Override
        public void process(Exchange exchange) throws Exception {
            Profile legacyProfile = exchange.getIn().getBody(Profile.class);
            // some more processing here
            exchange.getIn().setBody(legacyProfile);
        }

    });
在上面的路径中,我从一个文件中读取xml,然后使用jaxb转换器将感兴趣的元素映射到由“Profile”表示的类中。调用此路由后,CAMEL调用ProfileAggregationStrategy。代码是-

    public class ProfileAggregationStrategy implements AggregationStrategy{
       @Override
       public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
             // this is the problematic line
             Profile newProfile = newExchange.getIn().getBody(Profile.class);
             if (oldExchange == null){
                 return newExchange;
             } else {
                 Profile oldProfile = oldExchange.getIn().getBody(Profile.class);
                 // code to copy merge oldProfile with newProfile
                 return oldExchange;
             }

        }
    }

问题在于该行标记为“问题行”。即使在路由“direct:xmlProfile”的最后阶段,我已经显式地将一个对象放入了exchange主体中,ProfileAggregationStrategy中的newExchange仍然显示主体是iostream类型

阅读有关拆分器eip的文档

因为拆分器的输出就是输入,除非您为拆分器指定聚合策略,在该策略中您可以决定输出应该是什么。例如,如果要使用最后一个拆分的元素,则可以使用
uselastSetAggregationStrategy