You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2017/04/19 16:16:03 UTC

[4/4] camel git commit: ServiceCall : add documentation about LoadBalancer in ServiceCall EIP doc

ServiceCall : add documentation about LoadBalancer in ServiceCall EIP doc


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/3e7b1cfd
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/3e7b1cfd
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/3e7b1cfd

Branch: refs/heads/master
Commit: 3e7b1cfdd4a69b45a51b2505ad4079e32a0ff9d1
Parents: ecc8192
Author: lburgazzoli <lb...@gmail.com>
Authored: Wed Apr 19 18:15:17 2017 +0200
Committer: lburgazzoli <lb...@gmail.com>
Committed: Wed Apr 19 18:15:17 2017 +0200

----------------------------------------------------------------------
 .../src/main/docs/eips/serviceCall-eip.adoc     | 97 ++++++++++++++++++++
 1 file changed, 97 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/3e7b1cfd/camel-core/src/main/docs/eips/serviceCall-eip.adoc
----------------------------------------------------------------------
diff --git a/camel-core/src/main/docs/eips/serviceCall-eip.adoc b/camel-core/src/main/docs/eips/serviceCall-eip.adoc
index 35965ea..0874eef 100644
--- a/camel-core/src/main/docs/eips/serviceCall-eip.adoc
+++ b/camel-core/src/main/docs/eips/serviceCall-eip.adoc
@@ -334,6 +334,89 @@ from("direct:start")
 </camelContext>
 ----
 
+### Load Balancer
+
+The Service Call EIP comes with its own Load Balancer which is istantiated by default if a custome one is not configured and glues Service Discovery, Service Filer, Service Chooser and Service Expression togheter to load balance requests among the available services.
+
+If you need a more sophisticate load balancer you can use Ribbon by adding camel-ribbon to the mix, maven users will need to add the following dependency to their pom.xml
+
+[source,xml]
+----
+<dependency>
+    <groupId>org.apache.camel</groupId>
+    <artifactId>camel-ribbon</artifactId>
+    <!-- use the same version as your Camel core version -->
+    <version>x.y.z</version>
+</dependency>
+----
+
+*Available options:*
+
+[width="100%",cols="3,1m,6",options="header"]
+|=======================================================================
+| Name | Java Type | Description
+| clientName | String | The Ribbon client name
+| roperties | List<PropertyDefinition> | Custom client config properties
+|=======================================================================
+
+To leverage Ribbon, it is required to explicit enable it:
+
+[source,java]
+.Java DSL
+----
+from("direct:start")
+    .serviceCall("foo")
+        .ribbonLoadBalancer()
+    .to("mock:result");
+----
+
+[source,xml]
+.XML DSL
+----
+<camelContext xmlns="http://camel.apache.org/schema/spring">
+  <route>
+    <from uri="direct:start"/>
+    <serviceCall name="foo">
+      <ribbonLoadBalancer/>
+    </serviceCall>
+    <to uri="mock:result"/>
+  </route>
+</camelContext>
+----
+
+
+You can configure Ribbon key programmaticaly using RibbonConfiguration:
+
+[source,java]
+.Java DSL
+----
+RibbonConfiguration configuration = new RibbonConfiguration();
+configuration.addProperty("listOfServers", "localhost:9090,localhost:9091");
+
+from("direct:start")
+    .serviceCall("foo")
+        .loadBalancer(new RibbonServiceLoadBalancer(configuration))
+    .to("mock:result");
+----
+
+Or leveraging XML specific configuration:
+
+[source,xml]
+.XML DSL
+----
+<camelContext xmlns="http://camel.apache.org/schema/spring">
+  <route>
+    <from uri="direct:start"/>
+    <serviceCall name="foo">
+      <ribbonLoadBalancer>
+          <properties key="listOfServers" value="localhost:9090,localhost:9091"/>
+      </ribbonLoadBalancer>
+    </serviceCall>
+    <to uri="mock:result"/>
+  </route>
+</camelContext>
+----
+
 ### Shared configurations
 
 The Service CAll EIP can be configured straight on the route definition or through shared configurations, here an example with two configurations registered in the Camel Context:
@@ -418,3 +501,17 @@ public class MyRouteBuilder implements RouteBuilder {
     }
 }
 ----
+
+### Spring Cloud support
+
+If you are using Camel in an application based on Spring Cloud, you can leverage Spring Cloud service discovery and load balancing capabilities by adding the Spring Cloud related dependencies (i.e. spring-cloud-consul, spring-cloud-kubernetes) as any Spring Boot/Cloud application in addition to Camel's own camel-spring-cloud dependency.
+
+[source,xml]
+----
+<dependency>
+    <groupId>org.apache.camel</groupId>
+    <artifactId>camel-spring-cloud dependency</artifactId>
+    <!-- use the same version as your Camel core version -->
+    <version>x.y.z</version>
+</dependency>
+----