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

查看:24
本文介绍了如果一条路线配置错误,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 不会启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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