Search in sources :

Example 1 with RibbonConfiguration

use of org.apache.camel.component.ribbon.RibbonConfiguration in project camel by apache.

the class RibbonServiceCallUpdateRouteTest method createRouteBuilder.

@Override
protected RoutesBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            RibbonConfiguration configuration = new RibbonConfiguration();
            // lets update quick so we do not have to sleep so much in the tests
            configuration.setClientConfig(Collections.singletonMap("ServerListRefreshInterval", "250"));
            RibbonLoadBalancer loadBalancer = new RibbonLoadBalancer(configuration);
            from("direct:start").serviceCall().name("myService").loadBalancer(loadBalancer).serviceDiscovery(servers).end().to("mock:result");
            from("jetty:http://localhost:9090").routeId("9090").to("mock:9090").transform().constant("9090");
            from("jetty:http://localhost:9091").routeId("9091").to("mock:9091").transform().constant("9091");
        }
    };
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) RibbonConfiguration(org.apache.camel.component.ribbon.RibbonConfiguration)

Example 2 with RibbonConfiguration

use of org.apache.camel.component.ribbon.RibbonConfiguration in project camel by apache.

the class RibbonServiceCallRegistryRouteTest method createRouteBuilder.

@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("localhost", 9090);
            servers.addServer("localhost", 9091);
            RibbonConfiguration configuration = new RibbonConfiguration();
            RibbonLoadBalancer loadBalancer = new RibbonLoadBalancer(configuration);
            // configure camel service call
            ServiceCallConfigurationDefinition config = new ServiceCallConfigurationDefinition();
            config.setLoadBalancer(loadBalancer);
            config.setServiceDiscovery(servers);
            // register configuration
            context.setServiceCallConfiguration(config);
            from("direct:start").serviceCall("myService").to("mock:result");
            from("jetty:http://localhost:9090").to("mock:9090").transform().constant("9090");
            from("jetty:http://localhost:9091").to("mock:9091").transform().constant("9091");
        }
    };
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) StaticServiceDiscovery(org.apache.camel.impl.cloud.StaticServiceDiscovery) RibbonConfiguration(org.apache.camel.component.ribbon.RibbonConfiguration) ServiceCallConfigurationDefinition(org.apache.camel.model.cloud.ServiceCallConfigurationDefinition)

Example 3 with RibbonConfiguration

use of org.apache.camel.component.ribbon.RibbonConfiguration in project camel by apache.

the class RibbonServiceCallRouteTest method createRouteBuilder.

@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("localhost", 9090);
            servers.addServer("localhost", 9091);
            RibbonConfiguration configuration = new RibbonConfiguration();
            RibbonLoadBalancer loadBalancer = new RibbonLoadBalancer(configuration);
            from("direct:start").serviceCall().name("myService").loadBalancer(loadBalancer).serviceDiscovery(servers).end().to("mock:result");
            from("jetty:http://localhost:9090").to("mock:9090").transform().constant("9090");
            from("jetty:http://localhost:9091").to("mock:9091").transform().constant("9091");
        }
    };
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) StaticServiceDiscovery(org.apache.camel.impl.cloud.StaticServiceDiscovery) RibbonConfiguration(org.apache.camel.component.ribbon.RibbonConfiguration)

Aggregations

RouteBuilder (org.apache.camel.builder.RouteBuilder)3 RibbonConfiguration (org.apache.camel.component.ribbon.RibbonConfiguration)3 StaticServiceDiscovery (org.apache.camel.impl.cloud.StaticServiceDiscovery)2 ServiceCallConfigurationDefinition (org.apache.camel.model.cloud.ServiceCallConfigurationDefinition)1