Search in sources :

Example 1 with ContextAwareRequest

use of org.springframework.cloud.netflix.ribbon.support.ContextAwareRequest in project spring-cloud-netflix by spring-cloud.

the class AbstractRibbonCommand method run.

@Override
protected ClientHttpResponse run() throws Exception {
    final RequestContext context = RequestContext.getCurrentContext();
    RQ request = createRequest();
    RS response;
    boolean retryableClient = this.client instanceof AbstractLoadBalancingClient && ((AbstractLoadBalancingClient) this.client).isClientRetryable((ContextAwareRequest) request);
    if (retryableClient) {
        response = this.client.execute(request, config);
    } else {
        response = this.client.executeWithLoadBalancer(request, config);
    }
    context.set("ribbonResponse", response);
    // 
    if (this.isResponseTimedOut()) {
        if (response != null) {
            response.close();
        }
    }
    return new RibbonHttpResponse(response);
}
Also used : ContextAwareRequest(org.springframework.cloud.netflix.ribbon.support.ContextAwareRequest) RequestContext(com.netflix.zuul.context.RequestContext) RibbonHttpResponse(org.springframework.cloud.netflix.ribbon.RibbonHttpResponse) AbstractLoadBalancingClient(org.springframework.cloud.netflix.ribbon.support.AbstractLoadBalancingClient)

Aggregations

RequestContext (com.netflix.zuul.context.RequestContext)1 RibbonHttpResponse (org.springframework.cloud.netflix.ribbon.RibbonHttpResponse)1 AbstractLoadBalancingClient (org.springframework.cloud.netflix.ribbon.support.AbstractLoadBalancingClient)1 ContextAwareRequest (org.springframework.cloud.netflix.ribbon.support.ContextAwareRequest)1