You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (Jira)" <ji...@apache.org> on 2021/12/29 09:19:00 UTC

[jira] [Commented] (CAMEL-17393) Source locations are not available in Spring Boot configurations

    [ https://issues.apache.org/jira/browse/CAMEL-17393?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17466369#comment-17466369 ] 

Claus Ibsen commented on CAMEL-17393:
-------------------------------------

You cannot use spring <beans> XML files, its the fast xml parser that has this feature (camel-xml-io) - not the legacy jaxb parser.

> Source locations are not available in Spring Boot configurations
> ----------------------------------------------------------------
>
>                 Key: CAMEL-17393
>                 URL: https://issues.apache.org/jira/browse/CAMEL-17393
>             Project: Camel
>          Issue Type: Bug
>          Components: came-core, jmx
>    Affects Versions: 3.15.0
>            Reporter: Eugene Berman
>            Priority: Major
>
> I modified the SpringBoot XML example so that it configures routes and route contexts as Spring beans, e.g.:
> {code:xml}
> <?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} &gt; 4</simple>
>                 <transform>
>                     <simple>Random ${body}</simple>
>                 </transform>
>             </filter>
>             <to uri="stream:out"/>
>         </route>
>     </routeContext>
> </spring:beans>
> {code}
> I ran the application and called dumpRouteSourceLocationsAsXml from Jconsole. The response was:
> {code:xml}
> <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>
> {code}
> 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:
> {code:xml}
> <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>
> {code}
> So it seems like a bit more work is needed to support Spring configurations.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)