当前位置:网站首页>[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

边栏推荐
- MySQL -- index of InnoDB storage engine
- Contents of other parts of the map
- 用JpaTransactionManager操作数据库事务
- Jerry's burning of upper version materials requires [chapter]
- flutter Unable to load asset: assets/images/888.png
- 轉載csdn文章操作
- CKS CKA CKAD 将终端更改为远程桌面
- Istio, ebpf and rsocket Broker: in depth study of service grid
- Force buckle 710 Random numbers in the blacklist
- 测试人进阶技能:单元测试报告应用指南
猜你喜欢

Design of ESP automatic download circuit

【Kotlin 第三方 】coil koltin协程图片加载库Coil类似Glide的图片加载第三方

思科--高可用和高可靠网络考试
![[MySQL] basic use of explain and the function of each column](/img/d6/64f65ba21f5cda2c409477705f6a79.png)
[MySQL] basic use of explain and the function of each column
![Jielizhi Bluetooth headset quality control and production skills [chapter]](/img/3e/571d246d211a979e948dae1de56e93.png)
Jielizhi Bluetooth headset quality control and production skills [chapter]

YOGA27多维一体电脑,兼具出色外观与高端配置

Cisco exam -- redundant network

Detailed explanation of twenty common software testing methods (the most complete in History)

使用3DMax制作一个象棋棋子
![Jielizhi, production line assembly link [chapter]](/img/84/73637de7ba334c5ac48895a7e82575.png)
Jielizhi, production line assembly link [chapter]
随机推荐
Use of locust
玻璃马赛克
【Swoole系列1】在Swoole的世界中,你将学习到什么?
Jielizhi, production line assembly link [chapter]
Tcpdump command usage details
Mysql 5.7 实现 rank 排名
mysql binlog的清理
实在RPA:银行数字化,业务流程自动化“一小步”,贷款审核效率“一大步”
Deadlock handling strategies - prevent deadlock, avoid deadlock, detect and remove deadlock
RPA: Bank digitalization, business process automation "a small step", and loan review efficiency "a big step"
攻防演习防御体系构建之第三篇之建立实战化的安全体系
Microservice stability management
MySQL -- index of InnoDB storage engine
The online beggar function of Japanese shopping websites
Wechat personal small store one click opening assistant applet development
Using emqx cloud to realize one machine one secret verification of IOT devices
Daily question brushing record (10)
正则系列之组和范围(Groups and Ranges)
测试人进阶技能:单元测试报告应用指南
AirServer最新Win64位个人版投屏软件