use of org.apache.camel.impl.cloud.HealthyServiceFilter in project camel by apache.
the class ServiceCallDefinition method retrieveServiceFilter.
// ******************************************
// ServiceFilter
// ******************************************
private ServiceFilter retrieveServiceFilter(CamelContext camelContext, Function<CamelContext, ServiceCallConfigurationDefinition> function) throws Exception {
ServiceFilter answer = null;
ServiceCallConfigurationDefinition config = function.apply(camelContext);
if (config != null) {
if (config.getServiceFilterConfiguration() != null) {
answer = config.getServiceFilterConfiguration().newInstance(camelContext);
} else {
answer = retrieve(ServiceFilter.class, camelContext, config::getServiceFilter, config::getServiceFilterRef);
}
if (answer == null) {
String ref = config.getServiceFilterRef();
if (ObjectHelper.equal("healthy", ref, true)) {
answer = new HealthyServiceFilter();
} else if (ObjectHelper.equal("pass-through", ref, true)) {
answer = new PassThroughServiceFilter();
} else if (ObjectHelper.equal("passthrough", ref, true)) {
answer = new PassThroughServiceFilter();
}
}
}
return answer;
}
use of org.apache.camel.impl.cloud.HealthyServiceFilter in project camel by apache.
the class CamelCloudServiceFilterAutoConfiguration method serviceFilter.
@Lazy
@Bean(name = "service-filter")
public CamelCloudServiceFilter serviceFilter(CamelCloudConfigurationProperties properties) {
BlacklistServiceFilter blacklist = new BlacklistServiceFilter();
Map<String, List<String>> services = properties.getServiceFilter().getBlacklist();
for (Map.Entry<String, List<String>> entry : services.entrySet()) {
for (String part : entry.getValue()) {
String host = StringHelper.before(part, ":");
String port = StringHelper.after(part, ":");
if (ObjectHelper.isNotEmpty(host) && ObjectHelper.isNotEmpty(port)) {
blacklist.addServer(entry.getKey(), host, Integer.parseInt(port));
}
}
}
return new CamelCloudServiceFilter(Arrays.asList(new HealthyServiceFilter(), blacklist));
}
Aggregations