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

查看:181
本文介绍了如果一条路由配置错误,CamelContext不会启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用Java DSL来配置路由.路由的所有配置都在db表中,并且可以通过GUI进行配置.

即使路由配置错误(例如,路由中的.to(invalidurl or typo)或路由中的错误),如何确保camelContext启动?

是否可以在开始之前验证路由,或者更好地设置一些可以在上下文本身上设置的参数/选项?

解决方案

您可以使用.autoStartup(false)配置路由,然后在CamelContext启动后手动启动路由.

根据它的种类真正验证它.如果它是数据库的某个组件,则可以编写一些代码以执行SQL查询,以查看用户的有效登录名或其他内容.

要验证端点uri是否配置错误,则这比较困难,因为它们有很多选择.但这从Camel 2.16开始得到了改进,在构建期间我们拥有一些工具,这些工具会生成带有选项的json模式文件,然后我们可以在解析路由期间利用它来尝试检查无效的配置,然后再尝试创建可以甚至使用IDE插件或其他第三方工具,也可以更快地检测到错误.

We use Java DSL to configure our routes. All configurations for routes are in a db table and can be configured via a GUI.

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?

解决方案

You can configure the routes with .autoStartup(false), and then start the routes manually when CamelContext has been started up.

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.

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天全站免登陆