0

我在春天有以下 XML DSL 上下文定义:

<beans>
    <camelContext>
        <route>
            <from uri="direct:foo"/>
            <split parallelProcessing="true">
                <simple>${body}</simple>
                <to uri="direct:bar"/>
            </split>
        </route>
    </camelContext>
</beans>

在我的测试中,我试图direct:bar像这样编织端点:

context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {

    @Override
    public void configure() throws Exception {
        weaveByToString(".*direct:bar.*").replace().to("mock:bar");
    }
});

这成功地工作。但是当路由开始时,会抛出一个异常说org.apache.camel.NoSuchBeanException: No bean could be found in the registry for: direct:bar

为什么?

可能是骆驼不支持编织里面分叉?

注意:使用以下 XML 一切正常:

<beans>
    <camelContext>
        <route>
            <from uri="direct:dummy"/>
            <to uri="direct:bar"/>
        </route>

        <route>
            <from uri="direct:foo"/>
            <split parallelProcessing="true">
                <simple>${body}</simple>
                <to uri="direct:dummy"/>
            </split>
        </route>
    </camelContext>
</beans>
4

1 回答 1

0

对于使用 Camel 2.7 描述的用例,我无法重现您的错误。这是我通过的测试:

@Test
public void test() throws Exception {

    context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {

        @Override
        public void configure() throws Exception {
            weaveByToString(".*direct:bar.*").replace().to("mock:bar");
        }
    });

    MockEndpoint mock = getMockEndpoint("mock:bar");
    mock.expectedMessageCount(1);

    template.sendBody("direct:foo", "this is a test");

    assertMockEndpointsSatisfied();
}

使用也开始路线camel:run而不抛出NoSuchBeanException.

于 2012-04-20T07:52:59.753 回答