先说一下源码
调用Feign服务的时候 执行的核心代码如下
package feign;
.......//省略import
/**
* Submits HTTP {@link Request requests}. Implementations are expected to be thread-safe.
*/
public interface Client {
/**
* Executes a request against its {@link Request#url() url} and returns a response.
*
* @param request safe to replay.
* @param options options to apply to this request.
* @return connected response, {@link Response.Body} is absent or unread.
* @throws IOException on a network error connecting to {@link Request#url()}.
*/
Response execute(Request request, Options options) throws IOException;
public static class Default implements Client {
private final SSLSocketFactory sslContextFactory;
private final HostnameVerifier hostnameVerifier;
/**
* Null parameters imply platform defaults.
*/
public Default(SSLSocketFactory sslContextFactory, HostnameVerifier hostnameVerifier) {
this.sslContextFactory = sslContextFactory;
this.hostnameVerifier = hostnameVerifier;
}
@Override
public Response execute(Request request, Options options) throws IOException {
HttpURLConnection connection = convertAndSend(request, options);
return convertResponse(connection).toBuilder().request(request).build();
}
feign.client.Default#excute 方法会记录请求的信息。
到查理debug看看发出去的请求 能不能访问
feign:
hystrix:
enabled: true
如果断融器打开 会报错如下
2018-02-03 19:29:23.891 DEBUG [http-nio-9091-exec-7] [hio-portal] o.s.w.s.m.m.a.RequestResponseBodyMethodProcessor - Read [class java.lang.String] as "application/json;charset=UTF-8" with [org.springframework.http.converter.StringHttpMessageConverter@17361894]
com.netflix.hystrix.exception.HystrixRuntimeException: SysFeignService#queryListForQuickEntry(Map) timed-out and no fallback available.
at com.netflix.hystrix.AbstractCommand$22.call(AbstractCommand.java:805)
at com.netflix.hystrix.AbstractCommand$22.call(AbstractCommand.java:790)
at rx.internal.operators.OperatorOnErrorResumeNextViaFunction$4.onError(OperatorOnErrorResumeNextViaFunction.java:140)
at rx.internal.operators.OnSubscribeDoOnEach$DoOnEachSubscriber.onError(OnSubscribeDoOnEach.java:87)
at rx.internal.operators.OnSubscribeDoOnEach$DoOnEachSubscriber.onError(OnSubscribeDoOnEach.java:87)
a