use of org.apache.camel.impl.cloud.StaticServiceDiscovery 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.impl.cloud.StaticServiceDiscovery 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");
}
};
}
use of org.apache.camel.impl.cloud.StaticServiceDiscovery in project camel by apache.
the class CamelCloudServiceDiscoveryAutoConfiguration method staticServiceDiscovery.
@Lazy
@Bean(name = "static-service-discovery")
public ServiceDiscovery staticServiceDiscovery(CamelCloudConfigurationProperties properties) {
StaticServiceDiscovery staticServiceDiscovery = new StaticServiceDiscovery();
Map<String, List<String>> services = properties.getServiceDiscovery().getServices();
for (Map.Entry<String, List<String>> entry : services.entrySet()) {
staticServiceDiscovery.addServers(entry.getKey(), entry.getValue());
}
return staticServiceDiscovery;
}
Aggregations