mip
mip

Reputation: 2026

Starting and stopping Apache Camel routes from admin UI

I have a Apache Camel context which is part of a large Spring application. The application has a web based admin UI. I'd like to be able to stop/start/suspend/resume the camel routes from within this 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. My routes are defined in Java classes which extend SpringRouteBuilder.

I have:

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. I then have classes which extend SpringRouteBuilder in com.package

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?

Upvotes: 0

Views: 4077

Answers (1)

Claus Ibsen
Claus Ibsen

Reputation: 55555

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. All this is made easier by using an excellent library called jolokia (http://jolokia.org/) that makes JMX exposed as REST services. Each JMX operation/attribute is easily callable as an URI template over REST. And data is in json format.

That what you can build UI consoles that just use REST for communication, and are not tied into the Java or JMX world etc.

Also the Java API on CamelContext allows you to control routes. And there is also the control-bus EIP that has more details: http://camel.apache.org/controlbus

Upvotes: 4

Related Questions