问题描述
我们立足Karaf和Apache骆驼developped应用。虽然我们的应用程序,完全是基于包(OSGI),我们也加载骆驼上下文(和它的'路线上下文)在启动时,whcih将意味着我们已经定义了一些静态路由。
we have developped application based on Karaf and Apache Camel. While our application is entirely based on bundles ( OSGI ) we are also loading the Camel context ( and its' Route Contexts ) on startup, whcih would mean that we have defined some static routes.
我的问题是。有没有一种方法,而该应用程序,而不需要重读骆驼上下文,因为这将重置/重启已经存在的航线运行动态加载路线。这同样适用于已经创建路线,例如,如果我们想编辑whcih已存在的路由。
My question is. Is there a way to dynamically LOAD routes while the application is running without the need to reread the Camel Context as this will reset/restart the already existing routes. The same would apply to already created routes, for example if we want to edit a route whcih already exist.
整个想法是,我们正计划把路线在数据库中,因此,该数据库将通过GUI进行编辑。
The whole idea is that we are planning to put the routes in a database and as such, the database will be edited by a GUI.
那么,要做到这一点,最好的方法?我不敢相信这是真的,最好的办法重新加载OSGi包/添加在路由的情况下束,editted等等...
So what's the best approach to do this? I do not beleive that it is really the best approach to reload OSGI bundle/bundles in case of a route being added, editted etc...
应用程序的操作期间更多或更少,不同端点+他们相关的路由将被添加,编辑,删除。
More or less during operation of the application, Different endpoints + their related routes will be added, edited, removed.
请指教。
谢谢,
Tiho
Thanks,Tiho
推荐答案
我认为一个好的办法是将你的路线成小环境,每个环境只是几个(或者甚至单一的)路线。然后重新装入小范围内无其他线路造成中断。
I think a good approach is to group your routes into small contexts with just a few (or maybe even single) routes per context. Then you reload that small context without causing interruption in other routes.
不过,由于你不说的做法相信,你可以轻松地添加和对CamelContext方法删除路由。创建一个路由生成器,从数据库构建路线和使用addRoutes和removeRoute.
However, as you don't believe in that approach, you can easily add and remove routes with methods on the CamelContext. Create a route builder that constructs routes from your database and use addRoutes and removeRoute.
这篇关于加载在Apache的骆驼动态路由的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!