CamelContext doesn#39;t startup if one route is misconfigured(如果一条路线配置错误,CamelContext 不会启动)
问题描述
我们使用 Java DSL 来配置我们的路由.路由的所有配置都在一个 db 表中,可以通过 GUI 进行配置.
We use Java DSL to configure our routes. All configurations for routes are in a db table and can be configured via a GUI.
如何确保 camelContext
启动,即使路由配置错误(例如,路由中的 .to(invalidurl or typo)
或只是一个错误在一条路线上)?
How is it possible to ensure that the camelContext
starts up even if a route is misconfigured (e.g. .to(invalidurl or typo)
in a route or simply a bug in a route)?
是否有可能在开始之前验证路线,或者可以在上下文本身上设置一些更好的参数/选项?
Is there a possibilty to validate the routes before starting or maybe better some parameters/options which can be set on the context itself?
推荐答案
可以通过.autoStartup(false)配置路由,等CamelContext启动后手动启动路由.
You can configure the routes with .autoStartup(false), and then start the routes manually when CamelContext has been started up.
验证它真的取决于它是什么类型的组件.如果它是某个数据库组件,您可以编写一些代码来执行 SQL 查询,以查看是否是有效的用户登录或其他东西.
To validate its really depending on what kind of component it is. If its some database component you can write some code that does a SQL query to see if the is valid user login or something.
要验证端点 uri 是否配置错误,那就更难了,因为他们有很多选项.但这从 Camel 2.16 开始得到改进,在构建期间我们有一些工具可以生成带有选项的 json 模式文件,然后我们可能会在解析路由期间利用它来检查无效配置,然后再尝试创建可能的端点更快地检测到错误,甚至可以使用 IDE 插件或其他 3rd 方工具.
To validate that an endpoint uri is misconfigured, then that is harder as they have a ton of options. But this is getting improved from Camel 2.16 onwards where we have during build time some tooling that generates a json schema file with the options, then we could potentially leverage that during parsing the routes to check for invalid configuration before attempting to create the endpoints which could detect errors sooner, and even also with IDE plugins or other 3rd party tooling.
这篇关于如果一条路线配置错误,CamelContext 不会启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如果一条路线配置错误,CamelContext 不会启动


- Java包名称中单词分隔符的约定是什么? 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01