boot2.0.0.7release版本

Feign是受到Retrofit,JAXRS-2.0和WebSocket的影响,它是一个jav的到http客户端绑定的开源项目。 Feign的主要目标是将Java Http 客户端变得简单。Feign的源码地址:https://github.com/OpenFeign/feign

使用

现在来简单的实现一个Feign客户端,首先通过@FeignClient,客户端,其中value为调用其他服务的名称,FeignConfig.class为FeignClient的配置文件,代码如下:


@FeignClient(value = "service-hi",configuration = FeignConfig.class)
public interface SchedualServiceHi {@GetMapping(value = "/hi")String sayHiFromClientOne(@RequestParam(value = "name") String name);
}

其自定义配置文件如下,当然也可以不写配置文件,用默认的即可:

@Configuration
public class FeignConfig {@Beanpublic Retryer feignRetryer() {return new Retryer.Default(100, SECONDS.toMillis(1), 5);}}

总结

总到来说,Feign的源码实现的过程如下:

首先通过@EnableFeignCleints注解开启FeignCleint
根据Feign的规则实现接口,并加@FeignCleint注解
程序启动后,会进行包扫描,扫描所有的@ FeignCleint的注解的类,并将这些信息注入到ioc容器中。
当接口的方法被调用,通过jdk的代理,来生成具体的RequesTemplate
RequesTemplate在生成Request
Request交给Client去处理,其中Client可以是HttpUrlConnection、HttpClient也可以是Okhttp
最后Client被封装到LoadBalanceClient类,这个类结合类Ribbon做到了负载均衡。

FeignClient注解的源码

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface FeignClient {/*** The name of the service with optional protocol prefix. Synonym for {@link #name()* name}. A name must be specified for all clients, whether or not a url is provided.* Can be specified as property key, eg: ${propertyKey}.*/@AliasFor("name")String value() default "";/*** The service id with optional protocol prefix. Synonym for {@link #value() value}.** @deprecated use {@link #name() name} instead*/@DeprecatedString serviceId() default "";/*** The service id with optional protocol prefix. Synonym for {@link #value() value}.*/@AliasFor("value")String name() default "";/*** Sets the <code>@Qualifier</code> value for the feign client.*/String qualifier() default "";/*** An absolute URL or resolvable hostname (the protocol is optional).*/String url() default "";/*** Whether 404s should be decoded instead of throwing FeignExceptions*/boolean decode404() default false;/*** A custom <code>@Configuration</code> for the feign client. Can contain override* <code>@Bean</code> definition for the pieces that make up the client, for instance* {@link feign.codec.Decoder}, {@link feign.codec.Encoder}, {@link feign.Contract}.** @see FeignClientsConfiguration for the defaults*/Class<?>[] configuration() default {};/*** Fallback class for the specified Feign client interface. The fallback class must* implement the interface annotated by this annotation and be a valid spring bean.*/Class<?> fallback() default void.class;/*** Define a fallback factory for the specified Feign client interface. The fallback* factory must produce instances of fallback classes that implement the interface* annotated by {@link FeignClient}. The fallback factory must be a valid spring* bean.** @see feign.hystrix.FallbackFactory for details.*/Class<?> fallbackFactory() default void.class;/*** Path prefix to be used by all method-level mappings. Can be used with or without* <code>@RibbonClient</code>.*/String path() default "";/*** Whether to mark the feign proxy as a primary bean. Defaults to true.*/boolean primary() default true;}

FeignClient注解被@Target(ElementType.TYPE)修饰,表示FeignClient注解的作用目标在接口上;
@Retention(RetentionPolicy.RUNTIME),注解会在class字节码文件中存在,在运行时可以通过反射获取到;@Documented表示该注解将被包含在javadoc中。

feign 用于声明具有该接口的REST客户端的接口的注释应该是创建(例如用于自动连接到另一个组件。 如果功能区可用,那将是
用于负载平衡后端请求,并且可以配置负载平衡器
使用与伪装客户端相同名称(即值)@RibbonClient 。

其中value()和name()一样,是被调用的 service的名称。
url(),直接填写硬编码的url,decode404()即404是否被解码,还是抛异常;configuration(),标明FeignClient的配置类,默认的配置类为FeignClientsConfiguration类,可以覆盖Decoder、Encoder和Contract等信息,进行自定义配置。fallback(),填写熔断器的信息类。

FeignClient的配置

默认的配置类为FeignClientsConfiguration,这个类在spring-cloud-netflix-core的jar包下,打开这个类,可以发现它是一个配置类,注入了很多的相关配置的bean,包括feignRetryer、FeignLoggerFactory、FormattingConversionService等,其中还包括了Decoder、Encoder、Contract,如果这三个bean在没有注入的情况下,会自动注入默认的配置。

Decoder feignDecoder: ResponseEntityDecoder(这是对SpringDecoder的封装)
Encoder feignEncoder: SpringEncoder
Logger feignLogger: Slf4jLogger
Contract feignContract: SpringMvcContract

@Configuration
public class FeignClientsConfiguration {...//省略代码@Bean@ConditionalOnMissingBeanpublic Decoder feignDecoder() {return new ResponseEntityDecoder(new SpringDecoder(this.messageConverters));}@Bean@ConditionalOnMissingBeanpublic Encoder feignEncoder() {return new SpringEncoder(this.messageConverters);}@Bean@ConditionalOnMissingBeanpublic Contract feignContract(ConversionService feignConversionService) {return new SpringMvcContract(this.parameterProcessors, feignConversionService);}...//省略代码
}

重写配置:

你可以重写FeignClientsConfiguration中的bean,从而达到自定义配置的目的,比如FeignClientsConfiguration的默认重试次数为Retryer.NEVER_RETRY,即不重试,那么希望做到重写,写个配置文件,注入feignRetryer的bean,代码如下:

@Configuration
public class FeignConfig {@Beanpublic Retryer feignRetryer() {return new Retryer.Default(100, SECONDS.toMillis(1), 5);}}

在上述代码更改了该FeignClient的重试次数,重试间隔为100ms,最大重试时间为1s,重试次数为5次。

Feign的工作原理

feign是一个伪客户端,即它不做任何的请求处理。Feign通过处理注解生成request,从而实现简化HTTP API开发的目的,即开发人员可以使用注解的方式定制request api模板,在发送http request请求之前,feign通过处理注解的方式替换掉request模板中的参数,这种实现方式显得更为直接、可理解。

通过包扫描注入FeignClient的bean,该源码在FeignClientsRegistrar类:
首先在启动配置上检查是否有@EnableFeignClients注解,如果有该注解,则开启包扫描,扫描被@FeignClient注解接口。代码如下:

private void registerDefaultConfiguration(AnnotationMetadata metadata,BeanDefinitionRegistry registry) {Map<String, Object> defaultAttrs = metadata.getAnnotationAttributes(EnableFeignClients.class.getName(), true);if (defaultAttrs != null && defaultAttrs.containsKey("defaultConfiguration")) {String name;if (metadata.hasEnclosingClass()) {name = "default." + metadata.getEnclosingClassName();}else {name = "default." + metadata.getClassName();}registerClientConfiguration(registry, name,defaultAttrs.get("defaultConfiguration"));}}

程序启动后通过包扫描,当类有@FeignClient注解,将注解的信息取出,连同类名一起取出,赋给BeanDefinitionBuilder,然后根据BeanDefinitionBuilder得到beanDefinition,最后beanDefinition式注入到ioc容器中,源码如下:

public void registerFeignClients(AnnotationMetadata metadata,BeanDefinitionRegistry registry) {ClassPathScanningCandidateComponentProvider scanner = getScanner();scanner.setResourceLoader(this.resourceLoader);Set<String> basePackages;Map<String, Object> attrs = metadata.getAnnotationAttributes(EnableFeignClients.class.getName());AnnotationTypeFilter annotationTypeFilter = new AnnotationTypeFilter(FeignClient.class);final Class<?>[] clients = attrs == null ? null: (Class<?>[]) attrs.get("clients");if (clients == null || clients.length == 0) {scanner.addIncludeFilter(annotationTypeFilter);basePackages = getBasePackages(metadata);}else {final Set<String> clientClasses = new HashSet<>();basePackages = new HashSet<>();for (Class<?> clazz : clients) {basePackages.add(ClassUtils.getPackageName(clazz));clientClasses.add(clazz.getCanonicalName());}AbstractClassTestingTypeFilter filter = new AbstractClassTestingTypeFilter() {@Overrideprotected boolean match(ClassMetadata metadata) {String cleaned = metadata.getClassName().replaceAll("\\$", ".");return clientClasses.contains(cleaned);}};scanner.addIncludeFilter(new AllTypeFilter(Arrays.asList(filter, annotationTypeFilter)));}for (String basePackage : basePackages) {Set<BeanDefinition> candidateComponents = scanner.findCandidateComponents(basePackage);for (BeanDefinition candidateComponent : candidateComponents) {if (candidateComponent instanceof AnnotatedBeanDefinition) {// verify annotated class is an interfaceAnnotatedBeanDefinition beanDefinition = (AnnotatedBeanDefinition) candidateComponent;AnnotationMetadata annotationMetadata = beanDefinition.getMetadata();Assert.isTrue(annotationMetadata.isInterface(),"@FeignClient can only be specified on an interface");Map<String, Object> attributes = annotationMetadata.getAnnotationAttributes(FeignClient.class.getCanonicalName());String name = getClientName(attributes);registerClientConfiguration(registry, name,attributes.get("configuration"));registerFeignClient(registry, annotationMetadata, attributes);}}}}private void registerFeignClient(BeanDefinitionRegistry registry,AnnotationMetadata annotationMetadata, Map<String, Object> attributes) {String className = annotationMetadata.getClassName();BeanDefinitionBuilder definition = BeanDefinitionBuilder.genericBeanDefinition(FeignClientFactoryBean.class);validate(attributes);definition.addPropertyValue("url", getUrl(attributes));definition.addPropertyValue("path", getPath(attributes));String name = getName(attributes);definition.addPropertyValue("name", name);definition.addPropertyValue("type", className);definition.addPropertyValue("decode404", attributes.get("decode404"));definition.addPropertyValue("fallback", attributes.get("fallback"));definition.addPropertyValue("fallbackFactory", attributes.get("fallbackFactory"));definition.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_TYPE);String alias = name + "FeignClient";AbstractBeanDefinition beanDefinition = definition.getBeanDefinition();boolean primary = (Boolean)attributes.get("primary"); // has a default, won't be nullbeanDefinition.setPrimary(primary);String qualifier = getQualifier(attributes);if (StringUtils.hasText(qualifier)) {alias = qualifier;}BeanDefinitionHolder holder = new BeanDefinitionHolder(beanDefinition, className,new String[] { alias });BeanDefinitionReaderUtils.registerBeanDefinition(holder, registry);}

注入bean之后,通过jdk的代理,当请求Feign Client的方法时会被拦截,代码在ReflectiveFeign类,代码如下:

 public <T> T newInstance(Target<T> target) {Map<String, MethodHandler> nameToHandler = targetToHandlersByName.apply(target);Map<Method, MethodHandler> methodToHandler = new LinkedHashMap<Method, MethodHandler>();List<DefaultMethodHandler> defaultMethodHandlers = new LinkedList<DefaultMethodHandler>();for (Method method : target.type().getMethods()) {if (method.getDeclaringClass() == Object.class) {continue;} else if(Util.isDefault(method)) {DefaultMethodHandler handler = new DefaultMethodHandler(method);defaultMethodHandlers.add(handler);methodToHandler.put(method, handler);} else {methodToHandler.put(method, nameToHandler.get(Feign.configKey(target.type(), method)));}}InvocationHandler handler = factory.create(target, methodToHandler);T proxy = (T) Proxy.newProxyInstance(target.type().getClassLoader(), new Class<?>[]{target.type()}, handler);for(DefaultMethodHandler defaultMethodHandler : defaultMethodHandlers) {defaultMethodHandler.bindTo(proxy);}return proxy;}

在SynchronousMethodHandler类进行拦截处理,当被FeignClient的方法被拦截会根据参数生成RequestTemplate对象,该对象就是http请求的模板,代码如下:

 @Overridepublic Object invoke(Object[] argv) throws Throwable {RequestTemplate template = buildTemplateFromArgs.create(argv);Retryer retryer = this.retryer.clone();while (true) {try {return executeAndDecode(template);} catch (RetryableException e) {retryer.continueOrPropagate(e);if (logLevel != Logger.Level.NONE) {logger.logRetry(metadata.configKey(), logLevel);}continue;}}}

其中有个executeAndDecode()方法,该方法是通RequestTemplate生成Request请求对象,然后根据用client获取response。

  Object executeAndDecode(RequestTemplate template) throws Throwable {Request request = targetRequest(template);...//省略代码response = client.execute(request, options);...//省略代码}

Client组件

其中Client组件是一个非常重要的组件,Feign最终发送request请求以及接收response响应,都是由Client组件完成的,其中Client的实现类,只要有Client.Default,该类由HttpURLConnnection实现网络请求,另外还支持HttpClient、Okhttp.

首先来看以下在FeignRibbonClient的自动配置类,FeignRibbonClientAutoConfiguration ,主要在工程启动的时候注入一些bean,其代码如下:

@ConditionalOnClass({ ILoadBalancer.class, Feign.class })
@Configuration
@AutoConfigureBefore(FeignAutoConfiguration.class)
@EnableConfigurationProperties({ FeignHttpClientProperties.class })
//Order is important here, last should be the default, first should be optional
// see https://github.com/spring-cloud/spring-cloud-netflix/issues/2086#issuecomment-316281653
@Import({ HttpClientFeignLoadBalancedConfiguration.class,OkHttpFeignLoadBalancedConfiguration.class,DefaultFeignLoadBalancedConfiguration.class })
public class FeignRibbonClientAutoConfiguration {@Bean@Primary@ConditionalOnMissingBean@ConditionalOnMissingClass("org.springframework.retry.support.RetryTemplate")public CachingSpringLoadBalancerFactory cachingLBClientFactory(SpringClientFactory factory) {return new CachingSpringLoadBalancerFactory(factory);}@Bean@Primary@ConditionalOnMissingBean@ConditionalOnClass(name = "org.springframework.retry.support.RetryTemplate")public CachingSpringLoadBalancerFactory retryabeCachingLBClientFactory(SpringClientFactory factory,LoadBalancedRetryFactory retryFactory) {return new CachingSpringLoadBalancerFactory(factory, retryFactory);}@Bean@ConditionalOnMissingBeanpublic Request.Options feignRequestOptions() {return LoadBalancerFeignClient.DEFAULT_OPTIONS;}
}

在缺失配置feignClient的情况下,会自动注入new Client.Default(),跟踪Client.Default()源码,它使用的网络请求框架为HttpURLConnection,代码如下:
DefaultFeignLoadBalancedConfiguration

@Configuration
class DefaultFeignLoadBalancedConfiguration {@Bean@ConditionalOnMissingBeanpublic Client feignClient(CachingSpringLoadBalancerFactory cachingFactory,SpringClientFactory clientFactory) {return new LoadBalancerFeignClient(new Client.Default(null, null),cachingFactory, clientFactory);}
}

Client接口

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;}@Overridepublic Response execute(Request request, Options options) throws IOException {HttpURLConnection connection = convertAndSend(request, options);return convertResponse(connection).toBuilder().request(request).build();}
...
}

怎么在feign中使用HttpClient,查看HttpClientFeignLoadBalancedConfiguration 的注解即可

@Configuration
@ConditionalOnClass(ApacheHttpClient.class)
@ConditionalOnProperty(value = "feign.httpclient.enabled", matchIfMissing = true)
class HttpClientFeignLoadBalancedConfiguration {@Bean@ConditionalOnMissingBean(Client.class)public Client feignClient(CachingSpringLoadBalancerFactory cachingFactory,SpringClientFactory clientFactory, HttpClient httpClient) {ApacheHttpClient delegate = new ApacheHttpClient(httpClient);return new LoadBalancerFeignClient(delegate, cachingFactory, clientFactory);}

从代码@ConditionalOnClass(ApacheHttpClient.class)注解可知道,只需要在pom文件加上HttpClient的classpath就行了,另外需要在配置文件上加上feign.httpclient.enabled为true,从 @ConditionalOnProperty注解可知,这个可以不写,在默认的情况下就为true.

在pom文件加上:


<dependency><groupId>com.netflix.feign</groupId><artifactId>feign-httpclient</artifactId><version>RELEASE</version>
</dependency>

同理,如果想要feign使用Okhttp,则只需要在pom文件上加上feign-okhttp的依赖:

<dependency><groupId>com.netflix.feign</groupId><artifactId>feign-okhttp</artifactId><version>RELEASE</version>
</dependency>

feign的负载均衡

通过上述的FeignRibbonClientAutoConfiguration类配置Client的类型(httpurlconnection,okhttp和httpclient)时候,可知最终向容器注入的是LoadBalancerFeignClient,即负载均衡客户端。现在来看下LoadBalancerFeignClient的代码:

public class LoadBalancerFeignClient implements Client {static final Request.Options DEFAULT_OPTIONS = new Request.Options();private final Client delegate;private CachingSpringLoadBalancerFactory lbClientFactory;private SpringClientFactory clientFactory;public LoadBalancerFeignClient(Client delegate,CachingSpringLoadBalancerFactory lbClientFactory,SpringClientFactory clientFactory) {this.delegate = delegate;this.lbClientFactory = lbClientFactory;this.clientFactory = clientFactory;}@Overridepublic Response execute(Request request, Request.Options options) throws IOException {try {URI asUri = URI.create(request.url());String clientName = asUri.getHost();URI uriWithoutHost = cleanUrl(request.url(), clientName);FeignLoadBalancer.RibbonRequest ribbonRequest = new FeignLoadBalancer.RibbonRequest(this.delegate, request, uriWithoutHost);IClientConfig requestConfig = getClientConfig(options, clientName);return lbClient(clientName).executeWithLoadBalancer(ribbonRequest,requestConfig).toResponse();}catch (ClientException e) {IOException io = findIOException(e);if (io != null) {throw io;}throw new RuntimeException(e);}}

Client 接口只有一个抽象方法
Response execute(Request request, Options options) throws IOException;

AbstractLoadBalancerAwareClient

  public T executeWithLoadBalancer(final S request, final IClientConfig requestConfig) throws ClientException {RequestSpecificRetryHandler handler = getRequestSpecificRetryHandler(request, requestConfig);LoadBalancerCommand<T> command = LoadBalancerCommand.<T>builder().withLoadBalancerContext(this).withRetryHandler(handler).withLoadBalancerURI(request.getUri()).build();try {return command.submit(new ServerOperation<T>() {@Overridepublic Observable<T> call(Server server) {URI finalUri = reconstructURIWithServer(server, request.getUri());S requestForServer = (S) request.replaceUri(finalUri);try {return Observable.just(AbstractLoadBalancerAwareClient.this.execute(requestForServer, requestConfig));} catch (Exception e) {return Observable.error(e);}}}).toBlocking().single();} catch (Exception e) {Throwable t = e.getCause();if (t instanceof ClientException) {throw (ClientException) t;} else {throw new ClientException(e);}}}    

LoadBalancerCommand

   public Observable<T> submit(final ServerOperation<T> operation) {final ExecutionInfoContext context = new ExecutionInfoContext();if (listenerInvoker != null) {try {listenerInvoker.onExecutionStart();} catch (AbortExecutionException e) {return Observable.error(e);}}final int maxRetrysSame = retryHandler.getMaxRetriesOnSameServer();final int maxRetrysNext = retryHandler.getMaxRetriesOnNextServer();// Use the load balancerObservable<T> o = (server == null ? selectServer() : Observable.just(server)).concatMap(new Func1<Server, Observable<T>>() {@Override// Called for each server being selectedpublic Observable<T> call(Server server) {context.setServer(server);final ServerStats stats = loadBalancerContext.getServerStats(server);// Called for each attempt and retryObservable<T> o = Observable.just(server).concatMap(new Func1<Server, Observable<T>>() {@Overridepublic Observable<T> call(final Server server) {context.incAttemptCount();loadBalancerContext.noteOpenConnection(stats);if (listenerInvoker != null) {try {listenerInvoker.onStartWithServer(context.toExecutionInfo());} catch (AbortExecutionException e) {return Observable.error(e);}}final Stopwatch tracer = loadBalancerContext.getExecuteTracer().start();return operation.call(server).doOnEach(new Observer<T>() {private T entity;@Overridepublic void onCompleted() {recordStats(tracer, stats, entity, null);// TODO: What to do if onNext or onError are never called?}@Overridepublic void onError(Throwable e) {recordStats(tracer, stats, null, e);logger.debug("Got error {} when executed on server {}", e, server);if (listenerInvoker != null) {listenerInvoker.onExceptionWithServer(e, context.toExecutionInfo());}}@Overridepublic void onNext(T entity) {this.entity = entity;if (listenerInvoker != null) {listenerInvoker.onExecutionSuccess(entity, context.toExecutionInfo());}}                            private void recordStats(Stopwatch tracer, ServerStats stats, Object entity, Throwable exception) {tracer.stop();loadBalancerContext.noteRequestCompletion(stats, entity, exception, tracer.getDuration(TimeUnit.MILLISECONDS), retryHandler);}});}});if (maxRetrysSame > 0) o = o.retry(retryPolicy(maxRetrysSame, true));return o;}});if (maxRetrysNext > 0 && server == null) o = o.retry(retryPolicy(maxRetrysNext, false));return o.onErrorResumeNext(new Func1<Throwable, Observable<T>>() {@Overridepublic Observable<T> call(Throwable e) {if (context.getAttemptCount() > 0) {if (maxRetrysNext > 0 && context.getServerAttemptCount() == (maxRetrysNext + 1)) {e = new ClientException(ClientException.ErrorType.NUMBEROF_RETRIES_NEXTSERVER_EXCEEDED,"Number of retries on next server exceeded max " + maxRetrysNext+ " retries, while making a call for: " + context.getServer(), e);}else if (maxRetrysSame > 0 && context.getAttemptCount() == (maxRetrysSame + 1)) {e = new ClientException(ClientException.ErrorType.NUMBEROF_RETRIES_EXEEDED,"Number of retries exceeded max " + maxRetrysSame+ " retries, while making a call for: " + context.getServer(), e);}}if (listenerInvoker != null) {listenerInvoker.onExecutionFailed(e, context.toFinalExecutionInfo());}return Observable.error(e);}});}/*** Return an Observable that either emits only the single requested server* or queries the load balancer for the next server on each subscription*/private Observable<Server> selectServer() {return Observable.create(new OnSubscribe<Server>() {@Overridepublic void call(Subscriber<? super Server> next) {try {Server server = loadBalancerContext.getServerFromLoadBalancer(loadBalancerURI, loadBalancerKey);   next.onNext(server);next.onCompleted();} catch (Exception e) {next.onError(e);}}});}

最终负载均衡交给loadBalancerContext来处理,即之前讲述的Ribbon

cloud源码-Feign相关推荐

  1. Spring Cloud源码分析(二)Ribbon(续)

    因文章长度限制,故分为两篇.上一篇:<Spring Cloud源码分析(二)Ribbon> 负载均衡策略 通过上一篇对Ribbon的源码解读,我们已经对Ribbon实现的负载均衡器以及其中 ...

  2. java B2B2C Springboot电子商务平台源码-Feign 基本使用

    1. [microcloud-consumer-feign]为了可以使用到 feign 支持,需要修改 pom.xml 配置文件,引入相关依赖包:需要JAVA Spring Cloud大型企业分布式微 ...

  3. java B2B2C Springboot电子商务平台源码-Feign设计原理

    什么是Feign? 电子商务平台源码请加企鹅求求:一零三八七七四六二六.Feign 的英文表意为"假装,伪装,变形", 是一个http请求调用的轻量级框架,可以以Java接口注解的 ...

  4. cloud源码-Ribbon

    boot2.0.0.7release版本 什么是Ribbon Ribbon是Netflix公司开源的一个负载均衡的项目,它属于上述的第二种,是一个客户端负载均衡器,运行在客户端上.它是一个经过了云端测 ...

  5. java B2B2C Springcloud电子商务平台源码 -Feign之源码解析

    什么是Feign Feign是受到Retrofit,JAXRS-2.0和WebSocket的影响,它是一个jav的到http客户端绑定的开源项目. Feign的主要目标是将Java Http 客户端变 ...

  6. Spring Cloud源码分析(一)Eureka

    看过之前文章的朋友们,相信已经对Eureka的运行机制已经有了一定的了解.为了更深入的理解它的运作和配置,下面我们结合源码来分别看看服务端和客户端的通信行为是如何实现的.另外写这篇文章,还有一个目的, ...

  7. Spring Cloud源码分析(二)Ribbon

    断断续续看Ribbon的源码差不多也有7-8天了,总算告一段落.本文记录了这些天对源码的阅读过程与一些分析理解,如有不对还请指出. 友情提示:本文较长,请选择一个较为舒适的姿势来阅读 在之前介绍使用R ...

  8. Spring Cloud源码分析(四)Zuul:核心过滤器

    通过之前发布的<Spring Cloud构建微服务架构(五)服务网关>一文,相信大家对于Spring Cloud Zuul已经有了一个基础的认识.通过前文的介绍,我们对于Zuul的第一印象 ...

  9. Spring Cloud源码分析——Ribbon客户端负载均衡

    年前聊了Eureka和Zookeeper的区别,然后微服务架构系列就鸽了三个多月,一直沉迷逛B站,无法自拔.最近公司复工,工作状态慢慢恢复(又是元气满满地划水).本文从以下3个方面进行分析(参考了翟永 ...

最新文章

  1. R语言基本描述性统计量函数
  2. 自定义cacti插件监控jvm
  3. java的初始,Java初始
  4. javascript写字技巧_【iGeek手册】如何书写更加简洁的javascript代码?
  5. MySQL引擎innodb和mysum_mysql数据库引擎InnoDB和MyISAM
  6. 群晖nas怎么上传整个文件夹_你为什么需要一台NAS(第二期)
  7. python求最大素数_Python实现求最大公约数及判断素数的方法
  8. [USACO1.2]回文平方数 Palindromic Squares
  9. 去重复java_去重复数据(JAVA)
  10. Python的基础语法(二)
  11. 在SAP CRM呼叫中心里创建Service Request的实现技术
  12. 关于ICallbackEventHandler的疑问
  13. 【渝粤教育】国家开放大学2018年春季 0064-22T20世纪欧美文学 参考试题
  14. 跟我师兄聊天引发的思考
  15. 短信验证码倒计时代码
  16. 华为MatePad Pro 5G平板正式发布:售价5299元起!
  17. 树莓派3代B版板载WIFI配置
  18. 软件开发实践的24条军规
  19. Effective_STL 学习笔记(十六) 如何将 vector 和 string 的数据传给遗留的API
  20. SAP CDS View基础语法

热门文章

  1. npm ERR! code ENOENT npm ERR! syscall open npm ERR! errno -4058 npm ERR! enoent ENOENT: no such file
  2. 股票休市午间可以撤单吗?
  3. 家中没有电脑,怎么用手机清除路由器垃圾,或更换路由器密码?
  4. 退休的姐妹们,你们还打工吗?
  5. 有一天我突然接到他的电话
  6. 你觉得人生最好的年龄段是哪段时间?
  7. 给你揭密一个爆款文案套路,各行各业,谁用谁火
  8. 作为一个对电脑配置一概不知的人,怎样才能一步一步了解电脑构造并且由此来学会怎样自己配置电脑?
  9. In this year of Hors, he is an adopted son
  10. ubuntu下使用脚本自动禁用笔记本触摸板和键盘