当前位置:网站首页>Alibaba cloud microservices (I) service registry Nacos, rest template and feign client
Alibaba cloud microservices (I) service registry Nacos, rest template and feign client
2022-07-06 13:08:00 【Geometer】
First, let's introduce the concept of service registration
Actually DNS It is a service registration , In microservices . The application instance obtains the information of the service instance through the registry , Use this information to request the parameters they provide
There are ten instances of a service ,client How to know which one to visit ?
Service registration is needed to help us
First deploy a service center locally Nacos:
Start good nacos On the one hand, it can monitor API, On the one hand, there is a console
First, deploy a service End

You can see nacos You can find that the service has been registered to the service center 

Now deploy Consumer
consumer It can be used REST Template and Feign Client To write
Briefly introduce these two gadgets , They are all based on http Protocol to communicate
rest template It needs to be assembled every time url, It is relatively simple to use ,RestTemplate In splicing url When , You can specify ip Address + Port number , You can directly request the interface without going through the service registry ; You can also specify a service name , Request to go to the service registry first ( Such as nacos) Get the corresponding service ip Address + Port number , And then pass by HTTP Forward the request to the corresponding service interface ( need @LoadBalanced)
Feign The underlying implementation of is dynamic agent , Its use is realized through annotations , It is also mapped through the service center 
About feigin Use :
1. stay consumer add to @@EnableFeignClients
2. stay consumer add to Feign The interface of ( Use @FeignClient(value = “service-provider”), among value It refers to the services of producers ),producer Is the service that implements this interface
3. stay producer Created in controller Interface , Realization 2 The specific logic of the interface in
4. stay consumer Call in the
边栏推荐
- TYUT太原理工大学2022软工导论大题汇总
- Comparative analysis of the execution efficiency of MySQL 5.7 statistical table records
- [algorithm] sword finger offer2 golang interview question 6: sum of two numbers in the sorting array
- 《软件测试》习题答案:第一章
- [GNSS] robust estimation (robust estimation) principle and program implementation
- 最短Hamilton路径 (状压DP)
- 【GNSS】抗差估计(稳健估计)原理及程序实现
- TYUT太原理工大学2022数据库大题之概念模型设计
- rtklib单点定位spp使用抗差估计遇到的问题及解决
- [Chongqing Guangdong education] reference materials for regional analysis and planning of Pingdingshan University
猜你喜欢

基本Dos命令

微信小程序开发心得
![[algorithm] sword finger offer2 golang interview question 13: sum of numbers of two-dimensional submatrix](/img/17/e7c9bfa867030af97eb66a7932c7e3.png)
[algorithm] sword finger offer2 golang interview question 13: sum of numbers of two-dimensional submatrix

Edit distance (multi-source BFS)

TYUT太原理工大学2022软工导论大题汇总

MySQL 三万字精华总结 + 面试100 问,吊打面试官绰绰有余(收藏系列

【GNSS数据处理】赫尔默特(helmert)方差分量估计解析及代码实现

Iterable、Collection、List 的常见方法签名以及含义

Implementation of Excel import and export functions

Record: the solution of MySQL denial of access when CMD starts for the first time
随机推荐
Interview Essentials: talk about the various implementations of distributed locks!
TYUT太原理工大学2022软工导论大题汇总
IText 7 generate PDF summary
记录:动态Web项目servlet访问数据库404错误之解决
分支语句和循环语句
Basic DOS commands
KF UD decomposition pseudo code implementation advanced [2]
Fundamentals of UD decomposition of KF UD decomposition [1]
最短Hamilton路径 (状压DP)
Pride-pppar source code analysis
[算法] 剑指offer2 golang 面试题1:整数除法
[算法] 剑指offer2 golang 面试题6:排序数组中的两个数字之和
记录:下一不小心写了个递归
RTKLIB: demo5 b34f. 1 vs b33
2022 National Games RE1 baby_ tree
[算法] 剑指offer2 golang 面试题10:和为k的子数组
雇佣收银员【差分约束】
[algorithm] sword finger offer2 golang interview question 3: the number of 1 in the binary form of the first n numbers
GNSS positioning accuracy index calculation
Edit distance (multi-source BFS)