当前位置:网站首页>[micro service sentinel] sentinel integrates openfeign
[micro service sentinel] sentinel integrates openfeign
2022-07-01 23:12:00 【Bulst】
List of articles
step
We talked about sentinel Annotations @SentinelResource And its handling of abnormal disclosure scheme .
If each interface is handled separately , There will be many inconveniences , So we can integrate openfeign Unified treatment of current limiting and degradation strategies .
First step : open feign Yes sentinel Support for
feign:
sentinel:
enabled: true
The second step : Prepare the bottom plan
import com.ossa.feign.api.producer.ProducerFeign;
import org.springframework.stereotype.Service;
/** * @author issavior */
@Service
public class ProducerFeignFallback implements ProducerFeign {
@Override
public String producerById(String id) {
String msg = "fallback Current limiting method ";
return id + msg;
}
}
The third step : modify @FeignClient annotation
import com.ossa.feign.config.FeignClientConfig;
import com.ossa.feign.fallback.ProducerFeignFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
/** * @author issavior */
@FeignClient(value = "ossa-service-producer", configuration = FeignClientConfig.class,fallback = ProducerFeignFallback.class)
public interface ProducerFeign {
/** * according to ID Query products * * @param id The primary key of the item ID * @return Information about related products */
@GetMapping(value = "/producer/{id}")
String producerById(@PathVariable("id") String id);
}
problem
Problem description :
Caused by: java.lang.IllegalStateException: Ambiguous mapping
analysis :
stay feign On the interface @RequestMapping annotation , It will lead to this problem .
Controller This control layer request maps two methods , And in Controller It's repeated. , So wrong reporting . Or say , If there are two in a project @RequestMapping(“/xxx”) Exactly the same will report java.lang.IllegalStateException,controller The module depends on client It is the module that causes the conflict .
Solution :
Get rid of @RequestMapping
边栏推荐
- Preparation of functional test report
- Vsphere+ and vsan+ are coming! VMware hybrid cloud focus: native, fast migration, mixed load
- 攻防演习防御体系构建之第三篇之建立实战化的安全体系
- Explain ThreadLocal in detail
- Using emqx cloud to realize one machine one secret verification of IOT devices
- The principle, testing and Countermeasures of malicious software reverse closing EDR
- flutter Unable to load asset: assets/images/888.png
- 想请教一下,证券开户选择哪个证券比较好?手机开户是安全么?
- 【微服务|Sentinel】SentinelResourceAspect详解
- 通过Go语言创建CA与签发证书
猜你喜欢
玻璃马赛克
win 10 mstsc连接 RemoteApp
Summary of "performance testing" of software testing, novice will know the knowledge points on the road
Tcpdump command usage details
The online beggar function of Japanese shopping websites
flutter Unable to load asset: assets/images/888.png
Jielizhi, production line assembly link [chapter]
Turn -- use setjmp and longjmp in C language to realize exception capture and collaboration
CKS CKA ckad change terminal to remote desktop
马赛克后挡板是什么?
随机推荐
ECMAScript 2022 was officially released. Have you heard about it?
马赛克后挡板是什么?
Stimulate new kinetic energy and promote digital economy in multiple places
Use and function of spark analyze command map join broadcast join
使用3DMax制作一个象棋棋子
有些能力,是工作中学不来的,看看这篇超过90%同行
AAAI22 | 结构标记和交互建模:用于图分类的“SLIM”网络
Detailed explanation of twenty common software testing methods (the most complete in History)
mysql ---- Oracle中的rownum转换成MySQL
Unable to climb hill sort, directly insert sort
Cisco test -- the concept and configuration test of routing
YOGA27多维一体电脑,兼具出色外观与高端配置
mysql binlog的清理
Cisco -- highly available and reliable network examination
Genicam gentl standard ver1.5 (4) Chapter 5 acquisition engine
CKS CKA ckad change terminal to remote desktop
shell 自定义函数
Flynk SQL client uses comparison and is familiar with official documents
Contents of other parts of the map
Rank ranking with MySQL 5.7