apache-camel - 停止+中断现有路线
问题描述
我有一条正在等待锁的骆驼路线。让我们模拟如下:
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("timer://foo?period=100")
.to("direct:bar");
from("direct:bar")
.routeId("test")
.to("log:receive")
.process(new Processor() {
@Override
public void process(final Exchange exchange) throws Exception {
System.out.println("sleeping indefinitely");
try {
Thread.sleep(Long.MAX_VALUE);
} catch (final InterruptedException exception) {
exception.printStackTrace();
}
System.out.println("not sleeping indefinitely");
}
});
}
});
在某个时间点,我想尽快停止这test
条路线。有没有办法在中断当前处理这条路线的线程时停止这条路线?我尝试stopRoute
如下,但这似乎并没有中断线程。
context.getRouteController().stopRoute("test", 1, TimeUnit.NANOSECONDS);
我正在使用 Camel 版本 3.4.x。
解决方案
推荐阅读
- linux - 关于更改所有权和显示文件的 Linux 命令
- sql - 在 Oracle DB 中,有没有办法用一个命令在每一列上创建索引?
- python - On_member_join,缺少 2 个必需的位置参数:“members”和“member”
- c++ - 合并排序返回我输入的相同数组
- ruby-on-rails - Mini Test 和 Rails 6:在不同的测试中重用变量
- javascript - 安装反应应用程序时出错。安装 react 应用时出错
- sql - 用零 (0) 填充那些在日级别没有交易的客户(Teradata SQL 助手)
- translation - googletrans 在翻译时获得与输入相同的输出
- php - Amazon S3 在生产中工作,但不是来自本地主机
- javascript - 为对象数组中的每个唯一用户名生成平均时间