Apache camel Apache Camel EIP路由-如何停止拆分()

Apache camel Apache Camel EIP路由-如何停止拆分(),apache-camel,cxf,eip,Apache Camel,Cxf,Eip,我对以下路线有一些问题: // from("cxf:....")... from("direct:start").process(startRequestProcessor) // STEP 1 .choice() .when(body().isNull()) .to("direct:finish") .otherwise()

我对以下路线有一些问题:

// from("cxf:....")...
from("direct:start").process(startRequestProcessor) // STEP 1
            .choice()
                .when(body().isNull())
                        .to("direct:finish")
                .otherwise()
                    .split(body())  // STEP 2
                    .bean(TypeMapper.class) // STEP 3
                    .log("Goes to DynamicRouter:: routeByTypeHeader with header: ${headers.type}")
                    .recipientList().method(Endpoint1DynamicRouter.class, "routeByTypeHeader") // STEP 4
                    .ignoreInvalidEndpoints();

    from("direct:endpoint2") // STEP 6
            .log("Goes to DynamicRouter::routeByCollectionHeader with header: ${headers.collection}")
            .recipientList().method(Endpoint2DynamicRouter.class, "routeByCollectionHeader")
            .ignoreInvalidEndpoints();

    from("direct:endpoint1.1") // STEP 5
            .process(new DateRangeProcessor())
            .to("direct:collections");

    from("direct:endpoint1.2") // STEP 5
            .process(new SingleProcessor())
            .to("direct:collections");


    from("direct:endpoint2.2") // STEP 7
            .aggregate(header("collection" /** endpoint2.2 */), CollectionAggregationStrategy)
            .completionSize(exchangeProperty("endpoint22"))

            .process(new QueryBuilderProcessor())
            .bean(MyService, "getDbCriteria")

            .setHeader("collection", constant("endpoint2.1"))
            .to("direct:endpoint2.1").end();


    from("direct:endpoint2.1") // STEP 8
            .aggregate(header("collection" /** endpoint2.1 */), CollectionAggregationStrategy)
            .completionSize(exchangeProperty("CamelSplitSize"))
            .to("direct:finish").end();

    from("direct:finish")
            .process(new QueryBuilderProcessor())
            .bean(MyRepository, "findAll")
            .log("ResponseData: ${body}").
            marshal().json(JsonLibrary.Gson).end();
路线

  • 接收json字符串并将其转换为JSONObject的列表(哈希集)
  • 将收到的列表拆分为json对象
  • 根据对象内容设置相应的标题
  • 根据标头将消息路由到endpoint1.1或endpoint1.2
  • 将消息转换为mongodb标准并发送到endpoint2
  • Endpoint2根据另一个标头将消息路由到Endpoint2.1或Endpoint2.2
  • Endpoint2.2聚合所有接收到的消息,对其进行处理以获得mongodb标准,并将其发送到Endpoint2.1(completionSize在步骤2计算并保存在属性“endpoint22”中)
  • Enpoint2.1聚合所有消息(CamelSplitSize)将聚合消息转换为查询对象,并将其发送到存储库以检索数据
  • 我可以在调试器中看到有效的响应对象,但无论如何,我得到一个错误:

    未找到类java.util.HashSet,ContentType:application/json的消息正文编写器

    问题不在response对象中,因为它与其他路由一起工作,并且它不包含哈希集

    我猜route会将第1步创建的哈希集发送到输出

    我的问题是:

    • 路由输出中有什么错误
    • 两个recipientList()都尝试转发 发送到无效端点的消息(我必须使用.ignoreInvalidEndpoints()以避免异常):

      org.apache.camel.NoSuchEndpointException:找不到以下对象的终结点: org.springframework.data.mongodb.core.query。Criteria@20f55e70请 检查类路径是否包含所需的Camel组件jar

    任何帮助都将不胜感激
    谢谢。

    我觉得很奇怪,但是.aggregate()函数不回复exchange。它使用聚合策略,但始终回复传入的exchange。这在阅读文档时并不清楚,但您必须使用聚合策略和split()才能返回exchange