This is an automated email from the ASF dual-hosted git repository.
acosentino 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 05f1f58 Regen for commit c9ca10ce7e2014080280b00028eeed680a786b93
05f1f58 is described below
commit 05f1f589f150295a7a7d7e93554575e7f5ebdf0e
Author: orpiske <[email protected]>
AuthorDate: Mon Apr 19 09:35:50 2021 +0000
Regen for commit c9ca10ce7e2014080280b00028eeed680a786b93
Signed-off-by: GitHub <[email protected]>
---
camel-dependencies/pom.xml | 1 +
.../apache/camel/catalog/docs/serviceCall-eip.adoc | 56 +++++++++++++++++++---
2 files changed, 51 insertions(+), 6 deletions(-)
diff --git a/camel-dependencies/pom.xml b/camel-dependencies/pom.xml
index 3150ae1..fbbf771 100644
--- a/camel-dependencies/pom.xml
+++ b/camel-dependencies/pom.xml
@@ -504,6 +504,7 @@
<scribe-version>1.3.7</scribe-version>
<servicemix-specs-version>2.9.0</servicemix-specs-version>
<servlet-version-range>[3,4)</servlet-version-range>
+ <servo-version>0.10.1</servo-version>
<shiro-version>1.7.1</shiro-version>
<shrinkwrap-descriptors-version>2.0.0</shrinkwrap-descriptors-version>
<shrinkwrap-resolver-version>3.1.3</shrinkwrap-resolver-version>
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/serviceCall-eip.adoc
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/serviceCall-eip.adoc
index 19c1a73..3843794 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/serviceCall-eip.adoc
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/serviceCall-eip.adoc
@@ -379,7 +379,9 @@ And in XML
</camelContext>
----
-== Blacklist Service Filter
+== Service Filter
+
+=== Blacklist Service Filter
This service filter implementation removes the listed services from those
found by the service discovery.
Each service should be provided in the following form:
@@ -438,14 +440,56 @@ And in XML
</camelContext>
----
+=== Custom Service Filter
+
+Service Filters choose suitable candidates from the service definitions found
in the service discovery.
+
+As of Camel 3.10.0 they have access to the current exchange, which allows you
to create service filters
+comparing service metadata with message content.
+
+Assuming you have labeled one of the services in your service discovery to
support a certain type of requests:
+
+[source,java]
+----
+serviceDiscovery.addServer(new DefaultServiceDefinition("service",
"127.0.0.1", 1003,
+ Collections.singletonMap("supports", "foo")));
+----
+
+The current exchange has a property which says that it needs a foo service:
+
+[source,java]
+----
+exchange.setProperty("needs", "foo")
+----
+
+You can then use a `ServiceFilter` to select the service instances which match
the exchange:
+
+[source,java]
+----
+from("direct:start")
+ .serviceCall()
+ .name("service")
+ .serviceFilter((exchange, services) -> services.stream()
+ .filter(serviceDefinition ->
Optional.ofNullable(serviceDefinition.getMetadata()
+ .get("supports"))
+ .orElse("")
+ .equals(exchange.getProperty("needs",
String.class)))
+ .collect(Collectors.toList()));
+ .end()
+ .to("mock:result");
+----
+
== Load Balancer
-The Service Call EIP comes with its own Load Balancer which is instantiated by
default if a custom is not configured and
-glues Service Discovery, Service Filer, Service Chooser and Service Expression
together to load balance requests among the available services.
+The Service Call EIP comes with its own loadbalancer which is instantiated by
default if a custom loadbalancer is not configured. It glues Service Discovery,
Service Filter, Service Chooser and Service Expression together 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,
+If you need a more sophisticated 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
+NOTE: The `RibbonServiceLoadBalancer` has no concept of a current `Exchange`.
+Service filters therefore receive a dummy exchange when used with Ribbon.
+
+
[source,xml]
----
<dependency>
@@ -491,7 +535,7 @@ And in XML
</camelContext>
----
-You can configure Ribbon key programmatic using `RibbonConfiguration`:
+You can configure Ribbon key programmatically using `RibbonConfiguration`:
[source,java]
----
@@ -540,7 +584,7 @@ globalConf.setServiceChooser(
ServiceCallConfigurationDefinition httpsConf = new
ServiceCallConfigurationDefinition();
httpsConf.setServiceFilter(
- list -> list.stream().filter(s -> s.getPort() == 443).collect(toList())
+ list -> list.stream().filter((exchange, s) -> s.getPort() ==
443).collect(toList())
);
getContext().setServiceCallConfiguration(globalConf);