Chapter 3. Defining Camel routes
Camel Extensions for Quarkus supports the Java DSL language to define Camel Routes.
3.1. Java DSL
Extending org.apache.camel.builder.RouteBuilder
and using the fluent builder methods available there is the most common way of defining Camel Routes. Here is a simple example of a route using the timer component:
import org.apache.camel.builder.RouteBuilder; public class TimerRoute extends RouteBuilder { @Override public void configure() throws Exception { from("timer:foo?period=1000") .log("Hello World"); } }
3.1.1. Endpoint DSL
Since Camel 3.0, you can use fluent builders also for defining Camel endpoints. The following is equivalent with the previous example:
import org.apache.camel.builder.RouteBuilder; import static org.apache.camel.builder.endpoint.StaticEndpointBuilders.timer; public class TimerRoute extends RouteBuilder { @Override public void configure() throws Exception { from(timer("foo").period(1000)) .log("Hello World"); } }
Builder methods for all Camel components are available via camel-quarkus-core
, but you still need to add the given component’s extension as a dependency for the route to work properly. In case of the above example, it would be camel-quarkus-timer
.