in cafe-endpointdsl/src/main/java/org/apache/camel/example/cafe/CafeRouteBuilder.java [56:83]
public void runCafeRouteDemo() throws Exception {
// create CamelContext
CamelContext camelContext = new DefaultCamelContext();
// bind beans to the Camel
bindBeans(camelContext.getRegistry());
// add the routes
camelContext.addRoutes(this);
// add additional routes using inlined RouteBuilder
// where we can access the Camel Endpoint DSL from this class
RouteBuilder.addRoutes(camelContext, rb ->
rb.from(timer("myTimer").fixedRate(true).period(500).advanced().synchronous(false))
.delay(simple("${random(250,1000)}"))
.process(this::newOrder)
.to(direct("cafe")));
// start Camel
camelContext.start();
// just run for 10 seconds and stop
System.out.println("Running for 10 seconds and then stopping");
Thread.sleep(10000);
// stop and shutdown Camel
camelContext.stop();
}