java读取路由列表信息,如何查找路由的所有端点(Apache Camel,Java)

本文介绍如何在CamelContext中定位由特定Route(如myRoute1)创建的所有endpoint,包括通过Route ID过滤输出、获取Route Definition并筛选To Definition对象。
摘要由CSDN通过智能技术生成

I have several routes and many endpoints in Camel context. So need to get all endpoints created by one Route:

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();

And before stop I need get all endpoints which created by myRoute1 ??? for example:

1.file://data/outbox

2.mock://someway

3.http://website.com/file.txt

4.file://data/inbox?noop=true

I can get only all Endpoints of Camel context as: context.getEndpoints()

解决方案

You could try the following:

Give your route an routeId to be able to identify it later.

Get the RouteDefinition from the Route from the CamelContext and filter the List of Outputs for the ToDefinition objects.

List outputProcessorDefs = exchange.getContext().getRouteDefinition("[routeId]").getOutputs();

// Iterate and get all ProcessorDefinition objects which inherit from the ToDefinition

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值