首页 > 解决方案 > 如何在 Apache Camel 测试中模拟多播内部的路由

问题描述

如何在 Apache Camel 测试中模拟多播内部的路由

在 Cameltest 中模拟多播中的路由时出现错误,我可能错过了一些东西或者我错误地这样做了

请看下面的代码片段:

// RouteBuilder class
from(direct("get-data-id"))
    .routeId("direct:get-data-id")
    .setProperty("id", simple("${headers.id}"))
    .multicast(new ImplAggregationStrategy()).parallelProcessing()
        .to(direct("get-data-service-route"))
    .end()
    .setBody(DatasonnetExpression.builder("payload", String.class)
        .bodyMediaType(MediaTypes.APPLICATION_JAVA)
        .outputMediaType(MediaTypes.APPLICATION_JSON))
;
// Camel Test
routeToTest = "direct:get-data-id";
RouteDefinition routeDefinition = context.getRouteDefinition(routeToTest);
AdviceWith.adviceWith(routeDefinition, context, new AdviceWithRouteBuilder() {
    @Override
    public void configure() throws Exception {
        weaveByToString(".*get-data-service-route.*")
            .replace()
            .setBody(datasonnet("resource:classpath:/data/get-persons-personId-response.json", LinkedCaseInsensitiveMap.class));

        weaveAddLast().to("mock:result");
    }
});

错误日志:

java.lang.IllegalArgumentException: There are no outputs which matches: .*get-data-service-route.* in the route: Route(direct:get-data-id)[From[direct://get-data-id] -> [OnException[[com.ms3_inc.camel.extensions.rest.exception.RestException] -> [process[Processor@0x18ac53e8], SetBody[com.datasonnet.document.DefaultDocument@c3177d5], 
.
.
.

标签: javaspring-bootapache-camel

解决方案


推荐阅读