且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在 Apache Camel 中动态加载路由的***方式

更新时间:2023-12-05 07:59:10

我认为一个好的方法是将你的路由分组到小的上下文中,每个上下文只有几个(甚至可能是单个)路由.然后你重新加载那个小上下文,而不会导致其他路由中断.

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 上的方法轻松添加和删除路由.创建一个路由构建器,从您的数据库构建路由并使用 addRoutesremoveRoute.

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.