当前位置:网站首页>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
边栏推荐
- All in one 1405: sum and product of prime numbers
- Fairygui bar subfamily (scroll bar, slider, progress bar)
- Basic DOS commands
- 抗差估计在rtklib的pntpos函数(标准单点定位spp)中的c代码实现
- [algorithm] sword finger offer2 golang interview question 1: integer division
- [算法] 剑指offer2 golang 面试题7:数组中和为0的3个数字
- One article to get UDP and TCP high-frequency interview questions!
- [algorithm] sword finger offer2 golang interview question 12: the sum of the left and right sub arrays is equal
- Detailed explanation of balanced binary tree is easy to understand
- wsl常用命令
猜你喜欢
2-year experience summary, tell you how to do a good job in project management
Several high-frequency JVM interview questions
Basic DOS commands
The port is occupied because the service is not shut down normally
图书管理系统小练习
系统设计学习(二)Design a key-value cache to save the results of the most recent web server queries
Ten minutes to thoroughly master cache breakdown, cache penetration, cache avalanche
What are the advantages of using SQL in Excel VBA
[algorithm] sword finger offer2 golang interview question 13: sum of numbers of two-dimensional submatrix
[算法] 剑指offer2 golang 面试题8:和大于或等于k的最短子数组
随机推荐
121道分布式面试题和答案
分支语句和循环语句
【干货】提升RTK模糊度固定率的建议之周跳探测
MySQL shutdown is slow
121 distributed interview questions and answers
基本Dos命令
The port is occupied because the service is not shut down normally
记录:动态Web项目servlet访问数据库404错误之解决
[算法] 剑指offer2 golang 面试题13:二维子矩阵的数字之和
初识C语言(下)
[algorithm] sword finger offer2 golang interview question 5: maximum product of word length
阿里云微服务(四) Service Mesh综述以及实例Istio
Code example of MATLAB reading GNSS observation value o file
抽象类和接口
Pride-pppar source code analysis
RTKLIB: demo5 b34f. 1 vs b33
[dry goods] cycle slip detection of suggestions to improve the fixed rate of RTK ambiguity
阿里云微服务(一)服务注册中心Nacos以及REST Template和Feign Client
Implementation of Excel import and export functions
TYUT太原理工大学2022软工导论大题汇总