如何在骆驼中动态添加和启动路线?

如何在骆驼中动态添加和启动路线?,第1张

如何在骆驼中动态添加和启动路线

我会创建一个动态的路线建设者,例如

public class MyRouteBuilder extends RouteBuilder { private String another; private String letter; public MyRouteBuilder(CamelContext context,String another, String letter) {     super(context);     this.another=another;     this.letter=letter; } @Override public void configure() throws Exception {     super.configure();     from("restlet:/"+another+"?restletMethods=GET")     .to("first:run_"+letter)     .to("second:jump_"+letter)     .to("third:fly_"+letter); }    }

并添加到某个事件,例如

public class ApplicationContextProvider implements ApplicationContextAware {    @Override    public void setApplicationContext(ApplicationContext context) throws BeansException {        camelContext=(CamelContext)context.getBean("mainCamelContext");        camelContext.addRoutes(new MyRouteBuilder(camelContext, "another1","A"));        camelContext.addRoutes(new MyRouteBuilder(camelContext, "another2","B"));..


欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/zaji/5501070.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-12
下一篇 2022-12-12

发表评论

登录后才能评论

评论列表(0条)

保存