Integration / Apache Camel Interview Questions
What is Camel Spring Boot and how do you configure routes as Spring beans?
camel-spring-boot auto-configures a CamelContext as a Spring bean and binds its lifecycle to the Spring ApplicationContext. Any class annotated with @Component that extends RouteBuilder is automatically discovered and added. The starter also exposes Camel properties under the camel.* namespace in application.properties.
org.apache.camel.springboot
camel-spring-boot-starter
4.5.0
// Route class:
@Component
public class InvoiceRoute extends RouteBuilder {
@Value("${app.input-dir}") String inputDir;
@Override
public void configure() {
from("file:" + inputDir + "?noop=true")
.routeId("invoice-route")
.to("direct:process");
}
}
# application.properties
camel.springboot.name=MyApp
camel.springboot.routes-include-pattern=classpath:routes/*.yaml
app.input-dir=/data/invoicesIn addition to Java DSL routes, camel-spring-boot supports YAML and XML DSL route definitions loaded from the classpath via camel.springboot.routes-include-pattern. Beans in the Spring application context are available in Camel routes via .bean(BeanClass.class) or by Spring name. Health checks and JMX management are auto-configured when the relevant starters are on the classpath.
More Related questions...