无法创建路由route1

时间:2017-11-22 06:36:18

标签: java spring apache-camel

我在解决这个异常时遇到了麻烦,我不知道我在哪里做错了。 这是例外。

org.apache.camel.spring.boot.CamelSpringBootInitializationException: java.lang.RuntimeException: org.apache.camel.FailedToCreateRouteException: Failed to create route route1 at: >>> Filter[bean[ref:filter method:accept] -> []] <<< in route: Route(route1)[[From[file:D:/copyy/?noop=true]] -> [Filter[be... because of Definition has no children on Filter[bean[ref:filter method:accept] -> []]

Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create route route1 at: >>> Aggregate[true -> []] <<< in route: Route(route1)[[From[file:D:/xml/?noop=true]] -> [Aggregate[t... because of Definition has no children on Aggregate[true -> []]
Caused by: java.lang.IllegalArgumentException: Definition has no children on Aggregate[true -> []]

这是我的路由器:

<bean id="AggregatorDemo" class="com.javainuse.AggregatorDemo"/> 
<route>
    <from uri="file:D:/xml/?noop=true" />
        <aggregate strategyRef="AggregatorDemo">
        <correlationExpression>
        <constant>true</constant>
        </correlationExpression>
        </aggregate>
        <log message=".....${body}...."></log>
        <to uri="file:D:/Xmlcopy" />
</route>

这是我正在使用的聚合器类。

public class AggregatorDemo implements AggregationStrategy{

 public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {

        if (oldExchange == null) {

            return newExchange;
        }

        String orders = oldExchange.getIn().getBody(String.class);
        String newLine = newExchange.getIn().getBody(String.class);


        orders = orders+ newLine;

        oldExchange.getIn().setBody(orders);


        return oldExchange;
 }

}

1 个答案:

答案 0 :(得分:2)

将这些内容移到<aggregate>

<log message=".....${body}...."></log>
<to uri="file:D:/Xmlcopy" />

所以汇总有孩子,例如

 <aggregate strategyRef="AggregatorDemo">
   <correlationExpression>
     <constant>true</constant>
   </correlationExpression>
   <log message=".....${body}...."></log>
   <to uri="file:D:/Xmlcopy" />
 </aggregate>