我在 Camel 上下文中有几条路线和许多端点。因此需要获取由一个路由创建的所有端点:
CamelContext context = new DefaultCamelContext();
RouteBuilder route1 = new RouteBuilder() {
public void configure() {
from("file:data/inbox?noop=true")
.routeId("myRoute1")
.enrich("http://website.com/file.txt")
.to("file:data/outbox")
.to("mock:someway");
}
};
RouteBuilder route2 = new RouteBuilder() {
public void configure() {
from("file:data/outbox?noop=true")
.routeId("myRoute2")
.to("mock:myMom");
}
};
context.addRoutes(route1);
context.addRoutes(route2);
context.start();
// TODO
context.stop();
在停止之前,我需要获取由 myRoute1 创建的所有端点???例如:
1.file://data/outbox 2.mock://someway 3. http://website.com/file.txt 4.file://data/inbox?noop=true
我只能得到骆驼上下文的所有端点:context.getEndpoints()
您可以尝试以下操作:
从 CamelContext 的 Route 中获取 RouteDefinition 并过滤 ToDefinition 对象的输出列表。
List<ProcessorDefinition> outputProcessorDefs = exchange.getContext().getRouteDefinition("[routeId]").getOutputs();
// Iterate and get all ProcessorDefinition objects which inherit from the ToDefinition
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句