当前位置:网站首页>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
边栏推荐
- Compile GDAL source code with nmake (win10, vs2022)
- [algorithm] sword finger offer2 golang interview question 8: the shortest subarray with a sum greater than or equal to K
- TYUT太原理工大学2022数据库大题之E-R图转关系模式
- [GNSS] robust estimation (robust estimation) principle and program implementation
- [rtklib 2.4.3 B34] version update introduction I
- Employment of cashier [differential constraint]
- 2年经验总结,告诉你如何做好项目管理
- Basic DOS commands
- [algorithm] sword finger offer2 golang interview question 7: 3 numbers with 0 in the array
- 继承和多态(下)
猜你喜欢

Wechat applet development experience

闇の連鎖(LCA+树上差分)

微信小程序开发心得
![[GNSS data processing] Helmert variance component estimation analysis and code implementation](/img/4e/ff0334cf9a2a37096778a8c5719a4e.jpg)
[GNSS data processing] Helmert variance component estimation analysis and code implementation

TYUT太原理工大学2022数据库之关系代数小题

TYUT太原理工大学2022数据库大题之E-R图转关系模式
![[算法] 剑指offer2 golang 面试题1:整数除法](/img/e6/f17135207b3540ec58e5a9eed54220.png)
[算法] 剑指offer2 golang 面试题1:整数除法
![[algorithm] sword finger offer2 golang interview question 1: integer division](/img/e6/f17135207b3540ec58e5a9eed54220.png)
[algorithm] sword finger offer2 golang interview question 1: integer division

C code implementation of robust estimation in rtklib's pntpos function (standard single point positioning spp)

On March 15, the official version of go 1.18 was released to learn about the latest features and usage
随机推荐
Experience summary of autumn recruitment of state-owned enterprises
Tyut Taiyuan University of technology 2022 introduction to software engineering examination question outline
异常:IOException:Stream Closed
4.30 dynamic memory allocation notes
Rt-ppp test using rtknavi
Detailed explanation of balanced binary tree is easy to understand
[Yu Yue education] guide business reference materials of Wuxi Vocational and Technical College of Commerce
【rtklib】在rtk下使用抗差自适应卡尔曼滤波初步实践
[algorithm] sword finger offer2 golang interview question 5: maximum product of word length
Exception: ioexception:stream closed
[algorithme] swordfinger offer2 golang question d'entrevue 2: addition binaire
[算法] 剑指offer2 golang 面试题10:和为k的子数组
几道高频的JVM面试题
Pride-pppar source code analysis
All in one 1405: sum and product of prime numbers
Record: Navicat premium can't connect to MySQL for the first time
MySQL backup -- common errors in xtrabackup backup
2-year experience summary, tell you how to do a good job in project management
Branch and loop statements
165. Compare version number - string