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/10/05 08:08:43 UTC
camel git commit: CAMEL-11882: ServiceDefinition.metadata not passed
to RibbonServiceLoadBalancer
Repository: camel
Updated Branches:
refs/heads/master 267cc222a -> 0ad3f6240
CAMEL-11882: ServiceDefinition.metadata not passed to
RibbonServiceLoadBalancer
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/0ad3f624
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/0ad3f624
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/0ad3f624
Branch: refs/heads/master
Commit: 0ad3f62402805ec0ae1a15a9cac210c7b8096e2e
Parents: 267cc22
Author: Peter Palaga <pp...@redhat.com>
Authored: Thu Oct 5 10:00:09 2017 +0200
Committer: lburgazzoli <lb...@gmail.com>
Committed: Thu Oct 5 10:08:01 2017 +0200
----------------------------------------------------------------------
.../ribbon/cloud/RibbonServiceLoadBalancer.java | 1 +
.../RibbonServiceCallRouteMetadataTest.java | 75 ++++++++++++++++++++
2 files changed, 76 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/0ad3f624/components/camel-ribbon/src/main/java/org/apache/camel/component/ribbon/cloud/RibbonServiceLoadBalancer.java
----------------------------------------------------------------------
diff --git a/components/camel-ribbon/src/main/java/org/apache/camel/component/ribbon/cloud/RibbonServiceLoadBalancer.java b/components/camel-ribbon/src/main/java/org/apache/camel/component/ribbon/cloud/RibbonServiceLoadBalancer.java
index b5415c3..cad443e 100644
--- a/components/camel-ribbon/src/main/java/org/apache/camel/component/ribbon/cloud/RibbonServiceLoadBalancer.java
+++ b/components/camel-ribbon/src/main/java/org/apache/camel/component/ribbon/cloud/RibbonServiceLoadBalancer.java
@@ -241,6 +241,7 @@ public class RibbonServiceLoadBalancer
serviceName,
service.getHost(),
service.getPort(),
+ service.getMetadata(),
service.getHealth()
);
http://git-wip-us.apache.org/repos/asf/camel/blob/0ad3f624/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/RibbonServiceCallRouteMetadataTest.java
----------------------------------------------------------------------
diff --git a/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/RibbonServiceCallRouteMetadataTest.java b/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/RibbonServiceCallRouteMetadataTest.java
new file mode 100644
index 0000000..a0ac463
--- /dev/null
+++ b/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/RibbonServiceCallRouteMetadataTest.java
@@ -0,0 +1,75 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.component.ribbon.cloud;
+
+import java.util.Collections;
+
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.ribbon.RibbonConfiguration;
+import org.apache.camel.impl.cloud.StaticServiceDiscovery;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class RibbonServiceCallRouteMetadataTest extends CamelTestSupport {
+ @Test
+ public void testServiceCall() throws Exception {
+ getMockEndpoint("mock:app1").expectedMessageCount(1);
+ getMockEndpoint("mock:app2").expectedMessageCount(1);
+ getMockEndpoint("mock:result").expectedMessageCount(2);
+
+ String out = template.requestBody("direct:start", null, String.class);
+ String out2 = template.requestBody("direct:start", null, String.class);
+ assertEquals("app2", out);
+ assertEquals("app1", out2);
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected RoutesBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ // setup a static ribbon server list with these 2 servers to start with
+ StaticServiceDiscovery servers = new StaticServiceDiscovery();
+ servers.addServer("myService", "localhost", 9090, Collections.singletonMap("contextPath", "app1"));
+ servers.addServer("myService", "localhost", 9090, Collections.singletonMap("contextPath", "app2"));
+
+ RibbonConfiguration configuration = new RibbonConfiguration();
+ RibbonServiceLoadBalancer loadBalancer = new RibbonServiceLoadBalancer(configuration);
+
+ from("direct:start")
+ .serviceCall()
+ .name("myService")
+ .expression().simple("jetty:http://${header.CamelServiceCallServiceHost}:${header.CamelServiceCallServicePort}/${header.CamelServiceCallServiceMeta[contextPath]}")
+ .loadBalancer(loadBalancer)
+ .serviceDiscovery(servers)
+ .end()
+ .to("mock:result");
+ from("jetty:http://localhost:9090/app1")
+ .to("mock:app1")
+ .transform().constant("app1");
+ from("jetty:http://localhost:9090/app2")
+ .to("mock:app2")
+ .transform().constant("app2");
+ }
+ };
+ }
+}
+