You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2019/06/18 03:55:55 UTC
[camel] branch master updated: Polished example
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new 762b5fc Polished example
762b5fc is described below
commit 762b5fc5072e4c7a0d7511e67855d5916e2b53bb
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Jun 18 05:55:41 2019 +0200
Polished example
---
examples/camel-example-cafe-endpointdsl/README.md | 11 +++++++----
examples/camel-example-cafe-endpointdsl/pom.xml | 3 ++-
.../java/org/apache/camel/example/cafe/CafeRouteBuilder.java | 10 ++++++++--
.../src/main/resources/features.xml | 4 ++--
4 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/examples/camel-example-cafe-endpointdsl/README.md b/examples/camel-example-cafe-endpointdsl/README.md
index 543fac7..59f1f06 100644
--- a/examples/camel-example-cafe-endpointdsl/README.md
+++ b/examples/camel-example-cafe-endpointdsl/README.md
@@ -1,12 +1,16 @@
-# Cafe Example
+# Cafe Example with Endpoint DSL
### Introduction
+This example uses the Camel Endpoint DSL to configure Camel endpoints using a type-safe Java endpoint DSL
+(eg fluent builder style).
+
This example shows how to work with splitter and aggregator to implement a Cafe demo.
-First It uses the splitter to dispatch the order, then sends the orders to barista by checking
+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.
+
### Build
You will need to compile this example first:
@@ -20,8 +24,7 @@ To run the example type
mvn camel:run
You can see the routing rules by looking at the java code in the
-`src/main/java directory` and the Spring XML configuration lives in
-`src/main/resources/META-INF/spring`
+`src/main/java` directory.
To stop the example hit <kbd>ctrl</kbd>+<kbd>c</kbd>
diff --git a/examples/camel-example-cafe-endpointdsl/pom.xml b/examples/camel-example-cafe-endpointdsl/pom.xml
index 76cdbc9..3bbb60b 100644
--- a/examples/camel-example-cafe-endpointdsl/pom.xml
+++ b/examples/camel-example-cafe-endpointdsl/pom.xml
@@ -30,7 +30,7 @@
<artifactId>camel-example-cafe-endpointdsl</artifactId>
<packaging>jar</packaging>
- <name>Camel :: Example :: Cafe using the Endpoint DSL</name>
+ <name>Camel :: Example :: Cafe :: Endpoint DSL</name>
<description>A cafe example showing how to work with Camel and the Endpoint DSL</description>
<properties>
@@ -40,6 +40,7 @@
<dependencies>
+ <!-- using camel with endpoint dsl -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-endpointdsl</artifactId>
diff --git a/examples/camel-example-cafe-endpointdsl/src/main/java/org/apache/camel/example/cafe/CafeRouteBuilder.java b/examples/camel-example-cafe-endpointdsl/src/main/java/org/apache/camel/example/cafe/CafeRouteBuilder.java
index af9a1fa..a7a1442 100644
--- a/examples/camel-example-cafe-endpointdsl/src/main/java/org/apache/camel/example/cafe/CafeRouteBuilder.java
+++ b/examples/camel-example-cafe-endpointdsl/src/main/java/org/apache/camel/example/cafe/CafeRouteBuilder.java
@@ -18,6 +18,7 @@ package org.apache.camel.example.cafe;
import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.builder.endpoint.EndpointRouteBuilder;
import org.apache.camel.builder.RouteBuilder;
@@ -30,7 +31,10 @@ import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.spi.Registry;
/**
- * A simple example router from Cafe Demo
+ * A simple example router from Cafe Demo.
+ *
+ * Notice how this RouteBuilder extends {@link EndpointRouteBuilder} which provides the support
+ * for Camel Endpoint DSL.
*/
public class CafeRouteBuilder extends EndpointRouteBuilder {
@@ -49,7 +53,7 @@ public class CafeRouteBuilder extends EndpointRouteBuilder {
public void runCafeRouteDemo() throws Exception {
// create CamelContext
- DefaultCamelContext camelContext = new DefaultCamelContext();
+ CamelContext camelContext = new DefaultCamelContext();
// bind beans to the Camel
bindBeans(camelContext.getRegistry());
@@ -57,6 +61,8 @@ public class CafeRouteBuilder extends EndpointRouteBuilder {
// 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)}"))
diff --git a/examples/camel-example-cafe-endpointdsl/src/main/resources/features.xml b/examples/camel-example-cafe-endpointdsl/src/main/resources/features.xml
index 960c101..0a9dae7 100644
--- a/examples/camel-example-cafe-endpointdsl/src/main/resources/features.xml
+++ b/examples/camel-example-cafe-endpointdsl/src/main/resources/features.xml
@@ -20,9 +20,9 @@
<features>
<repository>mvn:org.apache.camel.karaf/apache-camel/${project.version}/xml/features</repository>
- <feature name='camel-example-cafe' version='${project.version}'>
+ <feature name='camel-example-cafe-endpointdsl' version='${project.version}'>
<feature version="${project.version}">camel</feature>
- <bundle>mvn:org.apache.camel.example/camel-example-cafe/${project.version}</bundle>
+ <bundle>mvn:org.apache.camel.example/camel-example-cafe-endpointdsl/${project.version}</bundle>
</feature>
</features>
\ No newline at end of file