简体   繁体   English

从管理界面启动和停止Apache Camel路由

[英]Starting and stopping Apache Camel routes from admin UI

I have a Apache Camel context which is part of a large Spring application. 我有一个Apache Camel上下文,它是一个大型Spring应用程序的一部分。 The application has a web based admin UI. 该应用程序具有基于Web的管理UI。 I'd like to be able to stop/start/suspend/resume the camel routes from within this UI. 我希望能够从此UI内停止/开始/暂停/恢复骆驼路线。 How can I achieve this? 我该如何实现?

Currently my Camel context is defined in a Spring context file and autostarts when the Spring application is deployed. 目前,我的Camel上下文是在Spring上下文文件中定义的,并在部署Spring应用程序时自动启动。 My routes are defined in Java classes which extend SpringRouteBuilder. 我的路由在扩展SpringRouteBuilder的Java类中定义。

I have: 我有:

camel-context.xml: camel-context.xml:

<beans>

    <!--bootstrap camel context-->
    <camelContext xmlns="http://camel.apache.org/schema/spring">
        <package>com.package</package>
    </camelContext>

</beans>

which is imported in the main Spring context. 这是在主要的Spring上下文中导入的。 I then have classes which extend SpringRouteBuilder in com.package 然后,我有了在com.package中扩展SpringRouteBuilder的类

Is there a better way of doing this so that I can programatically control the Camel context when there is an event in the UI? 有没有更好的方法来执行此操作,以便在UI中发生事件时可以以编程方式控制Camel上下文?

You can also do like we do in hawtio ( http://hawt.io/ ) where we use REST calls to remote manage Camel applications, so we can control routes, see statistic, view routes, and much more. 您也可以像在hawtio( http://hawt.io/ )中一样使用REST调用来远程管理Camel应用程序,因此我们可以控制路由,查看统计信息,查看路由等等。 All this is made easier by using an excellent library called jolokia ( http://jolokia.org/ ) that makes JMX exposed as REST services. 使用称为jolokia( http://jolokia.org/ )的出色库使所有这些操作变得容易,该库使JMX公开为REST服务。 Each JMX operation/attribute is easily callable as an URI template over REST. 每个JMX操作/属性都可以通过REST轻松地作为URI模板调用。 And data is in json format. 数据为json格式。

That what you can build UI consoles that just use REST for communication, and are not tied into the Java or JMX world etc. 那就是您可以构建仅使用REST进行通信且不与Java或JMX世界等捆绑在一起的UI控制台的功能。

Also the Java API on CamelContext allows you to control routes. 此外,CamelContext上的Java API还允许您控制路由。 And there is also the control-bus EIP that has more details: http://camel.apache.org/controlbus 还有控制总线EIP,它具有更多详细信息: http : //camel.apache.org/controlbus

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM