Return camel routes configuration to xml

I was wondering if it was possible to return all or part of routes from camel context – I’d like to make the configuration using Java and then to retrieve it to export it to xml.

Is there a way to achieve that? I haven’t found anything in documentation and I hope I just missed something and there is a way.

Answer

Yes, and what you are looking for is this JMX MBean interface:
http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/api/management/mbean/ManagedCamelContextMBean.html#dumpRoutesAsXml()

Basically JMX is enabled by default in Camel, so you can just connect to the JVM running Camel using a JMX console like JConsole. Then track down the CamelContext MBean like org.apache.camel:context=...,type=context,name=... and invoke the operation dumpRoutesAsXml(). And you’ll get all the routes in the Camel context as XML.

For more information on Camel and JMX, you may refer to this documentation as well:
http://camel.apache.org/camel-jmx.html

Leave a Reply

Your email address will not be published. Required fields are marked *