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");
}
};
}
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");
}
};
}
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");
}
};
}
Aggregations