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 16fddc9  CAMEL-14297: Introduce RouteBuilderConfigurer
16fddc9 is described below

commit 16fddc902c130299437e77d5160f1ff7a0a2af66
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Wed Aug 12 09:48:45 2020 +0200

    CAMEL-14297: Introduce RouteBuilderConfigurer
---
 docs/user-manual/modules/ROOT/nav.adoc             |  1 +
 docs/user-manual/modules/ROOT/pages/index.adoc     |  1 +
 .../ROOT/pages/route-builder-configurer.adoc       | 33 ++++++++++++++++++++++
 docs/user-manual/modules/ROOT/pages/routes.adoc    | 18 +++++++++++-
 4 files changed, 52 insertions(+), 1 deletion(-)

diff --git a/docs/user-manual/modules/ROOT/nav.adoc 
b/docs/user-manual/modules/ROOT/nav.adoc
index 4aa2aa4..cda67b2 100644
--- a/docs/user-manual/modules/ROOT/nav.adoc
+++ b/docs/user-manual/modules/ROOT/nav.adoc
@@ -80,6 +80,7 @@
 ** xref:processor.adoc[Processor]
 ** xref:registry.adoc[Registry]
 ** xref:route-builder.adoc[RouteBuilder]
+** xref:route-builder-configurer.adoc[RouteBuilderConfigurer]
 ** xref:route-controller.adoc[RouteController]
 ** xref:route-policy.adoc[RoutePolicy]
 ** xref:route-template.adoc[RouteTemplate]
diff --git a/docs/user-manual/modules/ROOT/pages/index.adoc 
b/docs/user-manual/modules/ROOT/pages/index.adoc
index 9a718bc..474929e 100644
--- a/docs/user-manual/modules/ROOT/pages/index.adoc
+++ b/docs/user-manual/modules/ROOT/pages/index.adoc
@@ -114,6 +114,7 @@ camel routes without them knowing
 * xref:processor.adoc[Processor]
 * xref:registry.adoc[Registry]
 * xref:route-builder.adoc[RouteBuilder]
+* xref:route-builder-configurer.adoc[RouteBuilderConfigurer]
 * xref:route-controller.adoc[RouteController]
 * xref:route-policy.adoc[RoutePolicy]
 * xref:route-template.adoc[RouteTemplate]
diff --git a/docs/user-manual/modules/ROOT/pages/route-builder-configurer.adoc 
b/docs/user-manual/modules/ROOT/pages/route-builder-configurer.adoc
new file mode 100644
index 0000000..cd70d50
--- /dev/null
+++ b/docs/user-manual/modules/ROOT/pages/route-builder-configurer.adoc
@@ -0,0 +1,33 @@
+[[RouteBuilderConfigurer-RouteBuilderConfigurer]]
+= RouteBuilderConfigurer
+
+The `RouteBuilderConfigurer` is a functional interface which is used for 
creating a routing rule using the DSL,
+using Java lambda style.
+
+[source,java]
+----
+rb -> rb.from("timer:foo").log("Hello Lambda");
+----
+
+Instances of RouteBuilderConfigurer are discovered and transformed into 
RouteBuilder instances
+which are added to the CamelContext.
+
+== Usage
+
+To use `RouteBuilderConfigurer` you need to create a method that returns 
`RouteBuilderConfigurer` which then
+allows to use Java lambda style to define a single route.
+
+In the example below the method myRoute is used to create a Camel route that 
consume from Kafka and send the messages to JMS.
+
+To make the route discoverable by Camel during startup, then the method must 
be annotated. In standalone mode with `camel-main`
+you should use `@BindToRegistry` and with Spring Boot use `@Bean` and with 
Quarkus then use `@Produce`.
+
+[source,java]
+----
+public class MyConfiguration {
+    @BindToRegistry
+    public RouteBuilderConfigurer myRoute() {
+        return rb -> rb.from("kafka:cheese").to("jms:queue:foo");
+    }
+}
+----
diff --git a/docs/user-manual/modules/ROOT/pages/routes.adoc 
b/docs/user-manual/modules/ROOT/pages/routes.adoc
index fd36c68..a647562 100644
--- a/docs/user-manual/modules/ROOT/pages/routes.adoc
+++ b/docs/user-manual/modules/ROOT/pages/routes.adoc
@@ -19,7 +19,6 @@ As you can see from the above Camel uses URIs to wire 
endpoints together.
 
 [[Routes-URI-String-Formatting]]
 == URI String formatting
-Since Camel 2.0
 
 If you have endpoint URIs that accept options and you want to be able to 
substitute the value, e.g. build the URI by concat the strings together, then 
you can use the java.lang.String.format method. But in Camel 2.0 we have added 
two convenient methods in the Java DSL so you can do fromF and toF that uses 
String formatting to build the URI.
 
@@ -47,6 +46,23 @@ RouteBuilder builder = new RouteBuilder() {
 };
 -------------------------------------------------------------
 
+[[Routes-Lambda]]
+== Routes using Java lambda style
+
+*Since Camel 3.5*
+
+Camel now supports to define Camel routes in Java DSL using Lambda style. This 
can be beneficial for microservices or serverless where
+you may want to quickly define a few routes.
+
+For example using lambda style you can define a Camel route that takes 
messages from Kafka and send to JMS in a single line of code:
+[source,java]
+----
+rb -> rb.from("kafka:cheese").to("jms:queue:foo");
+----
+
+There is a bit more to this as the lambda route must be coded in a Java method 
that returns an instance of `RouteBuilderConfigurer`.
+See more at the xref:route-builder-configurer.adoc[RouteBuilderConfigurer] 
documentation.
+
 [[Routes-Choices]]
 == Choices
 With a choice you provide a list of predicates and outcomes along with an 
optional default otherwise clause which is invoked if none of the conditions 
are met.

Reply via email to