Apache camel 如何使用AdviceWithRouteBuilder进行替换

Apache camel 如何使用AdviceWithRouteBuilder进行替换,apache-camel,Apache Camel,我在单元测试中使用AdviceWithRouteBuilder,我不确定replaceFromWith方法是如何工作的。我正在测试的路线如下所示: from(FTP_ENDPOINT) choice() when(predicateA) to("routeA") when(predicateB) to("routeB) otherwise() to("routeC");

我在单元测试中使用AdviceWithRouteBuilder,我不确定replaceFromWith方法是如何工作的。我正在测试的路线如下所示:

from(FTP_ENDPOINT)
    choice()
        when(predicateA)
            to("routeA")
        when(predicateB)
            to("routeB)
        otherwise()
            to("routeC");

from("routeA")
    to(SOMEWHERE)

from("routeB")
    to(SOMEWHER)

etc...
context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
    @Override
    public void configure() throws Exception {
        replaceFromWith("direct:start);
    }
});
我的单元测试使用AdviceWithRouteBuilder将FTP_端点替换为“direct:start”,如下所示:

from(FTP_ENDPOINT)
    choice()
        when(predicateA)
            to("routeA")
        when(predicateB)
            to("routeB)
        otherwise()
            to("routeC");

from("routeA")
    to(SOMEWHERE)

from("routeB")
    to(SOMEWHER)

etc...
context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
    @Override
    public void configure() throws Exception {
        replaceFromWith("direct:start);
    }
});

我的问题是,replaceFromWith如何知道要替换哪个端点?我只想替换FTP_端点。

您有3条路由,例如代码中的3 x from。在通知中,您选择第一条路线,当您说“get(0)”时,例如


因此它将使用第一条路线,您可以使用get(1)选择第二条路线。如果将id分配给路由,您还可以选择“按路由id”。

您有3条路由,例如代码中的3条。在通知中,您选择第一条路线,当您说“get(0)”时,例如

因此它将使用第一条路线,您可以使用get(1)选择第二条路线。如果为路线分配id,也可以选择“按路线id”