当前位置:网站首页>Automatic assembly and fuse degradation of feign
Automatic assembly and fuse degradation of feign
2022-07-25 21:38:00 【Xiaobai wants to become a big cow】
Use steps
The first step is to import feign rely on
<!-- Spring Cloud Microservice load balancing -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
</dependency>
<!-- Spring Cloud Microservice remote call -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<!--sentinel-->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>The second step is to configure feign
# Turn on feign The remote call of uses fusing
feign.sentinel.enabled = true
# Configuration request GZIP Compress
feign.compression.request.enabled = true
# Configure the minimum compressed data size
feign.compression.request.min-request-size = 2048
# Configure response GZIP Compress
feign.compression.response.enabled = true
# Configure compression support MIME TYPE
feign.compression.request.mime-types[0] = text/xml
feign.compression.request.mime-types[1] = application/xml
feign.compression.request.mime-types[2] = application/json
# Below is the setting feign Call yes, timeout, etc , Prevent avalanche
# Number of retries to the current instance default 0
ribbon.MaxAutoRetries = 1
# Set connection timeout default 2000
ribbon.ConnectTimeout = 3000
# Retry all operation requests default false
ribbon.OkToRetryOnAllOperations = false
# Set read timeout default 5000
ribbon.ReadTimeout = 20000
# Number of retries to switch instances default 1
ribbon.MaxAutoRetriesNextServer = 1The third step ( utilize spring Of SPI): stay resource Created in META-INF, also META-INF Created in spring.factories
org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.xuecheng.api.feign.config.FeignConfigMy waiting right points to mine feign Configuration class , such Spring When it starts , I will scan first resource.META-INF.spring.factories file , Scan the files pointed to inside ,
@Configuration
@ComponentScan(basePackages = {"com.xuecheng.api.feign"}) // This is to scan the path and add IOC Class in
@EnableFeignClients(basePackages = {"com.xuecheng.api.feign"}) // This is used to scan the path feign Give the annotated package to ioc management
public class FeignConfig {
}such spring Will be based on spring.factories Found the path specified in FeignConfig, By scanning FeignConfig See there are
@EnableFeignClients(basePackages = {"com.xuecheng.api.feign"}) // This is used to scan the path feign Give the annotated package to ioc management annotation , Will scan com.xuecheng.api.feign Under the use of Feign Related annotation class .
But if fuse is configured , But fusing is not used feign Relevant comments, so the above @EnableFeignClients It will not scan the package that is not used feign Related notes , Then you need to be in FeignConfig Add annotation to
@ComponentScan(basePackages = {"com.xuecheng.api.feign"}) // This is to scan the path and add IOC Class in Put all under this path @Componen Derived needs to be connected to IOC The class of the container is handed over to Spring management , And the fuse class is just under this path , That's it Feign Automatic assembly of
technological process :Spring start-up --------> Scan all in the project resource.META-INF.spring.factories Content ------> Find the specified FeignConfig class ---------------> adopt FeignConfig Annotations configured in @EnableFeignClients scanning feignj All uses under the package where the interface is located Feign Related annotation class , Add to IOC in ------------> If there is a fuse , adopt @ComponentScan Scan under the package where the fuse class is located All use @Componen And classes derived from annotations are added to IOC in .
So that's the end of it feign Integrated into the Spring in
边栏推荐
- [interview: concurrent 25: multithreading: volatile] visibility
- cuda_error_out_of_memory(out of memory怎么办)
- Airtest solves the problem that a password needs to be entered in the process of "automatic packaging" (the same applies to random bullet frame processing)
- 腾讯云数据库的可信可控之路
- Unity Metaverse(二)、Mixamo & Animator 混合树与动画融合
- 人脸与关键点检测:YOLO5Face实战
- 【面试:并发篇25:多线程:volatile】可见性
- How to solve the problem of high concurrency and large traffic with PHP
- [JS] the problem pointed by this
- ES6 --- four powerful operators (?,? =,?.,?:)
猜你喜欢

How to choose sentinel vs. hystrix current limiting?

函数栈帧的创建和销毁

Zero basic learning canoe panel (17) -- panel CAPL function
![[MAIXPY]kpu: load error:2005, ERR_READ_FILE: read file failed问题解决](/img/0b/da67b5a361a2cdfaf81568d34cf5f7.png)
[MAIXPY]kpu: load error:2005, ERR_READ_FILE: read file failed问题解决

Job interviews are always a second kill? After reading the seckill system notes secretly stored by JD T8, I have given my knees

Byte side: can TCP and UDP use the same port?

Sentinel vs Hystrix 限流对比,到底怎么选?

Detailed explanation of JVM memory model and structure (five model diagrams)

【Redis底层解析】链表类型

2022 latest examination questions and answers of eight members (standard staff) of Shanghai Architecture
随机推荐
The role of the resize function is "suggestions collection"
zigbee物联网开发平台(工业物联网)
Fusing and degrading Sentinel
Advanced technology management - how can the team be broken?
ZigBee IOT development platform (Industrial IOT)
Detailed explanation of several ideas for implementing timed tasks in PHP
【面试:并发篇25:多线程:volatile】可见性
cuda_error_out_of_memory(out of memory怎么办)
Blood spitting finishing nanny level series tutorial - playing Fiddler bag capturing tutorial (7) - Fiddler status panel -quickexec command line
Array of arm disassembly
ES6 --- four powerful operators (?,? =,?.,?:)
kali修改更新源(无法安全的用该源更新)
Research on the scheme of MySQL advanced (VIII) sorting problem
选择的能力
Optimization analysis of storage structure and IO performance of openharmony littlefs file system
Naming rules for BSP of Quanzhi chip
浅谈web性能优化(一)
Autojs learning - Automatic screenshot of the king
Interface testing tool restlet client
Autojs learning - file depth search