Integration / Apache Camel Interview Questions
What is a Route in Apache Camel and how do you define one using the Java DSL?
A Route is the fundamental unit of integration logic — a complete message flow: where messages originate (from()), what processing they undergo (EIPs, Processors, Beans), and where they are sent (to()). Each route runs as an independent pipeline inside the CamelContext, identified by a unique route ID.
public class OrderRoutes extends RouteBuilder {
@Override
public void configure() {
from("file:/orders/input?noop=true")
.routeId("file-to-jms")
.log("Processing: ${header.CamelFileName}")
.unmarshal().csv()
.split(body()).to("jms:queue:order-items").end();
from("jetty:http://0.0.0.0:8080/api/orders")
.routeId("http-router")
.choice()
.when(header("type").isEqualTo("express"))
.to("jms:queue:express-orders")
.otherwise().to("jms:queue:standard-orders")
.end();
}
}Key rules: exactly one from(uri) per route; to(uri) sends to a producer without ending the route; routeId() assigns a stable ID for monitoring and testing. In Spring Boot, annotate a RouteBuilder subclass with @Component for automatic registration by camel-spring-boot.
More Related questions...