Search code examples
apache-camelspring-camelcamel-ftp

Camel route should be annotated with component or configuration


I have camel route which basically used to move files from source to destination as below

public class SimpleRouteBuilder extends RouteBuilder {

    @Override
    public void configure() throws Exception {
        from("file:C:/inputFolder?noop=true").to("file:C:/outputFolder");
    }

}

Question is which annotation(@component or @Configuration) should be used to load this route


Solution

  • If you are using Spring or Spring Boot etc then it should be @Component which ensures the class is enlisted into the spring bean registry, which Camel then scans for RouteBuilder classes and automatic adds to the CamelContext.

    Mind that Spring Boot has some classpaths it only scans (I think its the package of the main class and sub packages), so if you put it inside other packages outside that, you may need to configure spring boot to scan for other packages.