Use serviceId as prefix for RibbonCommand hystrix command key
Fixes gh-160
This commit is contained in:
@@ -31,6 +31,7 @@ import com.netflix.config.DynamicIntProperty;
|
||||
import com.netflix.config.DynamicPropertyFactory;
|
||||
import com.netflix.hystrix.HystrixCommand;
|
||||
import com.netflix.hystrix.HystrixCommandGroupKey;
|
||||
import com.netflix.hystrix.HystrixCommandKey;
|
||||
import com.netflix.hystrix.HystrixCommandProperties;
|
||||
import com.netflix.hystrix.HystrixCommandProperties.ExecutionIsolationStrategy;
|
||||
import com.netflix.niws.client.http.RestClient;
|
||||
@@ -87,7 +88,8 @@ public class RibbonCommand extends HystrixCommand<HttpResponse> {
|
||||
HystrixCommandProperties.Setter setter = HystrixCommandProperties.Setter()
|
||||
.withExecutionIsolationStrategy(ExecutionIsolationStrategy.SEMAPHORE)
|
||||
.withExecutionIsolationSemaphoreMaxConcurrentRequests(value.get());
|
||||
return Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey(commandKey))
|
||||
return Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("RibbonCommand"))
|
||||
.andCommandKey(HystrixCommandKey.Factory.asKey(commandKey + "RibbonCommand"))
|
||||
.andCommandPropertiesDefaults(setter);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
|
||||
import lombok.extern.apachecommons.CommonsLog;
|
||||
|
||||
import org.springframework.cloud.netflix.ribbon.SpringClientFactory;
|
||||
import org.springframework.cloud.netflix.zuul.filters.ProxyRequestHelper;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
@@ -102,9 +103,10 @@ public class RibbonRoutingFilter extends ZuulFilter {
|
||||
}
|
||||
// remove double slashes
|
||||
uri = uri.replace("//", "/");
|
||||
String service = (String) context.get("serviceId");
|
||||
|
||||
try {
|
||||
HttpResponse response = forward(restClient, verb, uri, headers, params,
|
||||
HttpResponse response = forward(restClient, service, verb, uri, headers, params,
|
||||
requestEntity);
|
||||
setResponse(response);
|
||||
return response;
|
||||
@@ -116,12 +118,12 @@ public class RibbonRoutingFilter extends ZuulFilter {
|
||||
return null;
|
||||
}
|
||||
|
||||
private HttpResponse forward(RestClient restClient, Verb verb, String uri,
|
||||
private HttpResponse forward(RestClient restClient, String service, Verb verb, String uri,
|
||||
MultiValueMap<String, String> headers, MultiValueMap<String, String> params,
|
||||
InputStream requestEntity) throws Exception {
|
||||
Map<String, Object> info = this.helper.debug(verb.verb(), uri, headers, params,
|
||||
requestEntity);
|
||||
RibbonCommand command = new RibbonCommand(restClient, verb, uri,
|
||||
RibbonCommand command = new RibbonCommand(service, restClient, verb, uri,
|
||||
convertHeaders(headers), convertHeaders(params), requestEntity);
|
||||
try {
|
||||
HttpResponse response = command.execute();
|
||||
|
||||
Reference in New Issue
Block a user