2
votes

I would like to move several of our camel application to Spring Boot. Most of the examples I find are using the java dsl. The application we currently support are all based on Spring XML.

What steps should I take to migrate these application to Spring Boot. If I use FatJarRouter it is my understanding that a camel context is auto-cofigured already, so it seems to me I should be able to just define routes in spring xml.

@SpringBootApplication
@ImportResource("classpath:camel-context.xml")
public class CamelApplication extends FatJarRouter {

    public static void main(String[] args) {
        SpringApplication.run(CamelApplication.class, args);
    }

    @Bean
    String myBean() {
        return "I'm Spring bean!";
    }
}

camel-context.xml

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       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">
    <routes xmlns="http://camel.apache.org/schema/spring">
        <route id="test">
            <from uri="timer://trigger"/>
            <transform>
                <simple>ref:myBean</simple>
            </transform>
            <to uri="log:out"/>
        </route>
    </routes>
</beans>

Exception

2015-11-13 15:59:13.734  WARN 2156 --- [on(5)-127.0.0.1] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Cannot locate BeanDefinitionParser for element [routes]
Offending resource: class path resource [camel-context.xml]
    at org.springframework.beans.factory.parsing.FailFastProblemReporter.fatal(FailFastProblemReporter.java:60) ~[spring-beans-4.2.2.RELEASE.jar:na]
    at org.springframework.beans.factory.parsing.ReaderContext.fatal(ReaderContext.java:68) ~[spring-beans-4.2.2.RELEASE.jar:na]
1
Yeah we should make this easier. I have logged a ticket: issues.apache.org/jira/browse/CAMEL-9325Claus Ibsen
Should I still use the FatJarRouter?zachariahyoung

1 Answers

2
votes