如果一条路由配置错误,CamelContext 不会启动 [英] CamelContext doesn't startup if one route is misconfigured

查看:31
本文介绍了如果一条路由配置错误,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 Typ) 或只是一个错误)也能启动在路线中)?

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 不会启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆