Since we're on a major migration process of this website, some component documents here are out of sync right now. In the meantime you may want to look at the early version of the new website
https://camel.apache.org/staging/
We would very much like to receive any feedback on the new site, please join the discussion on the Camel user mailing list.
Cafe ExampleThis example shows how to use Camel to implement a Cafe use case. First It uses the splitter to dispatch the order, then sends the orders to barista by checking if the coffee is hot or cold. When the coffee is ready, we use a aggregate to gather the drinks for waiter to deliver. Here is the route builder code for it. Error rendering macro 'code': Invalid value specified for parameter 'java.lang.NullPointerException'@Override public void configure() { from("direct:cafe") .split().method("orderSplitter").to("direct:drink"); from("direct:drink").recipientList().method("drinkRouter"); from("seda:coldDrinks?concurrentConsumers=2").to("bean:barista?method=prepareColdDrink").to("direct:deliveries"); from("seda:hotDrinks?concurrentConsumers=3").to("bean:barista?method=prepareHotDrink").to("direct:deliveries"); from("direct:deliveries") .aggregate(new CafeAggregationStrategy()).method("waiter", "checkOrder").completionTimeout(5 * 1000L) .to("bean:waiter?method=prepareDelivery") .to("bean:waiter?method=deliverCafes"); } RunningYou will need to compile this example first: mvn compile The example should run if you type: mvn exec:java To stop the server hit ctrl + c Sample outputWhen the client is running it outputs all requests and responses on the screen. Camel thread 4: seda://coldDrinks?concurrentConsumers=2 prepared cold drink #1 for order #2: iced 2 shot ESPRESSO Camel thread 3: seda://hotDrinks?concurrentConsumers=3 prepared hot drink #1 for order #2: hot 2 shot MOCHA Camel thread 1: seda://hotDrinks?concurrentConsumers=3 prepared hot drink #2 for order #2: hot 4 shot CAPPUCCINO Camel thread 2: seda://hotDrinks?concurrentConsumers=3 prepared hot drink #3 for order #2: hot 4 shot LATTE ----------------------- Order #2 Iced ESPRESSO, 2 shots. Hot MOCHA, 2 shots. Hot CAPPUCCINO, 4 shots. Hot LATTE, 4 shots. ----------------------- See Also |