当前位置:网站首页>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软工导论简答题
- Record: I accidentally wrote a recursion next time
- 初识C语言(下)
- Code example of MATLAB reading GNSS observation value o file
- Ten minutes to thoroughly master cache breakdown, cache penetration, cache avalanche
- wsl常用命令
- 记录:newInstance()过时的代替方法
- [算法] 剑指offer2 golang 面试题3:前n个数字二进制形式中1的个数
猜你喜欢
Novatel board oem617d configuration step record
Answer to "software testing" exercise: Chapter 1
记录:初次cmd启动MySQL拒接访问之解决
如何保障 MySQL 和 Redis 的数据一致性?
【GNSS数据处理】赫尔默特(helmert)方差分量估计解析及代码实现
一文搞定 UDP 和 TCP 高频面试题!
Edit distance (multi-source BFS)
121 distributed interview questions and answers
Heap sort [handwritten small root heap]
On March 15, the official version of go 1.18 was released to learn about the latest features and usage
随机推荐
The port is occupied because the service is not shut down normally
165. Compare version number - string
微信小程序开发心得
TYUT太原理工大学往年数据库简述题
2022 National Games RE1 baby_ tree
[untitled]
《软件测试》习题答案:第一章
Several high-frequency JVM interview questions
[算法] 剑指offer2 golang 面试题9:乘积小于k的子数组
国企秋招经验总结
[Yu Yue education] guide business reference materials of Wuxi Vocational and Technical College of Commerce
[算法] 剑指offer2 golang 面试题3:前n个数字二进制形式中1的个数
WSL common commands
Iterable、Collection、List 的常见方法签名以及含义
Ten minutes to thoroughly master cache breakdown, cache penetration, cache avalanche
C code implementation of robust estimation in rtklib's pntpos function (standard single point positioning spp)
[GNSS data processing] Helmert variance component estimation analysis and code implementation
Compile GDAL source code with nmake (win10, vs2022)
Exception: ioexception:stream closed
[dry goods] cycle slip detection of suggestions to improve the fixed rate of RTK ambiguity