当前位置:网站首页>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
边栏推荐
- The port is occupied because the service is not shut down normally
- Excel导入,导出功能实现
- The earth revolves around the sun
- 编辑距离(多源BFS)
- TYUT太原理工大学2022软工导论简答题
- On March 15, the official version of go 1.18 was released to learn about the latest features and usage
- Rt-ppp test using rtknavi
- 【GNSS】抗差估计(稳健估计)原理及程序实现
- How to reduce the shutdown time of InnoDB database?
- Application architecture of large live broadcast platform
猜你喜欢
服务未正常关闭导致端口被占用
C code implementation of robust estimation in rtklib's pntpos function (standard single point positioning spp)
Fundamentals of UD decomposition of KF UD decomposition [1]
TYUT太原理工大学2022数据库之关系代数小题
One article to get UDP and TCP high-frequency interview questions!
Problems and solutions of robust estimation in rtklib single point location spp
使用rtknavi进行RT-PPP测试
系统设计学习(二)Design a key-value cache to save the results of the most recent web server queries
平衡二叉树详解 通俗易懂
MySQL shutdown is slow
随机推荐
Ten minutes to thoroughly master cache breakdown, cache penetration, cache avalanche
167. Sum of two numbers II - input ordered array - Double pointers
KF UD decomposition pseudo code implementation advanced [2]
MySQL 30000 word essence summary + 100 interview questions, hanging the interviewer is more than enough (Collection Series
[GNSS] robust estimation (robust estimation) principle and program implementation
几道高频的JVM面试题
[algorithm] sword finger offer2 golang interview question 3: the number of 1 in the binary form of the first n numbers
抗差估计在rtklib的pntpos函数(标准单点定位spp)中的c代码实现
TYUT太原理工大学2022数据库大题之分解关系模式
阿里云一面:并发场景下的底层细节 - 伪共享问题
记录:初次cmd启动MySQL拒接访问之解决
[算法] 剑指offer2 golang 面试题5:单词长度的最大乘积
Itext 7 生成PDF总结
Interview Essentials: talk about the various implementations of distributed locks!
XV Function definition and call
堆排序【手写小根堆】
使用rtknavi进行RT-PPP测试
[algorithm] sword finger offer2 golang interview question 4: numbers that appear only once
错误:排序与角标越界
[算法] 剑指offer2 golang 面试题2:二进制加法