Description
I modified the SpringBoot XML example so that it configures routes and route contexts as Spring beans, e.g.:
<?xml version="1.0" encoding="UTF-8"?> <spring:beans xmlns:spring="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://camel.apache.org/schema/spring" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd "> <routeContext id="test"> <route id="hello"> <from uri="timer:hello?period={{timer.period}}"/> <transform> <method ref="myBean" method="saySomething"/> </transform> <setProperty name="testRouteURI"> <constant>direct:test</constant> </setProperty> <setHeader name="number"> <simple>${random(0,10)}</simple> </setHeader> <filter> <simple>${header.number} > 4</simple> <transform> <simple>Random ${body}</simple> </transform> </filter> <to uri="stream:out"/> </route> </routeContext> </spring:beans>
I ran the application and called dumpRouteSourceLocationsAsXml from Jconsole. The response was:
<routeLocations> <routeLocation routeId="hello" id="hello" index="0" sourceLocation="file:/Users/foobar/camel-spring-boot-examples/xml/target/classes/camel/my-route.xml" sourceLineNumber="-1"/> <routeLocation routeId="hello" id="transform1" index="25" sourceLocation="file:/Users/foobar/camel-spring-boot-examples/xml/target/classes/camel/my-route.xml" sourceLineNumber="-1"/> <routeLocation routeId="hello" id="setProperty1" index="26" sourceLocation="file:/Users/foobar/camel-spring-boot-examples/xml/target/classes/camel/my-route.xml" sourceLineNumber="-1"/> <routeLocation routeId="hello" id="setHeader1" index="27" sourceLocation="file:/Users/foobar/camel-spring-boot-examples/xml/target/classes/camel/my-route.xml" sourceLineNumber="-1"/> <routeLocation routeId="hello" id="filter1" index="28" sourceLocation="file:/Users/foobar/camel-spring-boot-examples/xml/target/classes/camel/my-route.xml" sourceLineNumber="-1"/> <routeLocation routeId="hello" id="transform2" index="29" sourceLocation="" sourceLineNumber="-1"/> <routeLocation routeId="hello" id="to1" index="30" sourceLocation="file:/Users/foobar/camel-spring-boot-examples/xml/target/classes/camel/my-route.xml" sourceLineNumber="-1"/> </routeLocations>
I also wanted to have a custom Camel context configuration, so I explicitly created a Camel context XML file and added an annotation to the application class to exclude the CamelAutoConfiguration. This time source locations looked like this:
<routeLocations> <routeLocation routeId="hello" id="hello" index="0" sourceLocation="" sourceLineNumber="-1"/> <routeLocation routeId="hello" id="transform1" index="4" sourceLocation="" sourceLineNumber="-1"/> <routeLocation routeId="hello" id="setProperty1" index="5" sourceLocation="" sourceLineNumber="-1"/> <routeLocation routeId="hello" id="setHeader1" index="6" sourceLocation="" sourceLineNumber="-1"/> <routeLocation routeId="hello" id="filter1" index="7" sourceLocation="" sourceLineNumber="-1"/> <routeLocation routeId="hello" id="transform2" index="8" sourceLocation="" sourceLineNumber="-1"/> <routeLocation routeId="hello" id="to1" index="9" sourceLocation="" sourceLineNumber="-1"/> </routeLocations>
So it seems like a bit more work is needed to support Spring configurations.
Attachments
Issue Links
- is related to
-
CAMEL-17406 camel-core - InterceptFrom header with intercepted endpoint should be done without affecting model
- Resolved
- relates to
-
CAMEL-17405 camel-xml-io - Add source location to parsed models
- Resolved
- links to