[
https://issues.apache.org/jira/browse/CAMEL-11882?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16192581#comment-16192581
]
ASF GitHub Bot commented on CAMEL-11882:
----------------------------------------
GitHub user ppalaga opened a pull request:
https://github.com/apache/camel/pull/2005
CAMEL-11882: ServiceDefinition.metadata not passed to
RibbonServiceLoadBalancer
https://issues.apache.org/jira/browse/CAMEL-11882
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/ppalaga/camel CAMEL-11882
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/camel/pull/2005.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #2005
----
commit f6f16086d52b21a8a623efc44511fb836135fe6a
Author: Peter Palaga <[email protected]>
Date: 2017-10-05T08:00:09Z
CAMEL-11882: ServiceDefinition.metadata not passed to
RibbonServiceLoadBalancer
----
> ServiceDefinition.metadata not passed to RibbonServiceLoadBalancer
> ------------------------------------------------------------------
>
> Key: CAMEL-11882
> URL: https://issues.apache.org/jira/browse/CAMEL-11882
> Project: Camel
> Issue Type: Bug
> Components: camel-ribbon
> Reporter: Peter Palaga
> Assignee: Peter Palaga
>
> I tried to write a Ribbon Load Balancer test that would send requests to two
> application paths on the same server and port. Because
> {{org.apache.camel.cloud.ServiceDefinition}} has no notion of context path, I
> used the {{ServiceDefinition.metadata}} to define it and in the
> {{serviceCall}} I used an expression
> {{.expression().simple("jetty:http://${header.CamelServiceCallServiceHost}:${header.CamelServiceCallServicePort}/${header.CamelServiceCallServiceMeta[contextPath]}")}}
> to use it.
> However, the test is not passing because
> {{RibbonServiceLoadBalancer.RibbonServerList.asRibbonServerList(List<ServiceDefinition>)}}
> is not passing the medata map to {{RibbonServiceDefinition}}. The test
> passes as expected when {{RibbonServerList.asRibbonServerList()}} is fixed.
> Here is the test:
> {code}
> 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");
> }
> };
> }
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)