当前位置:网站首页>Explanation of service registration and discovery API of Nacos series
Explanation of service registration and discovery API of Nacos series
2022-06-13 05:38:00 【codain】
Nacos Provided by itself SDK and API To complete service registration and discovery ,SDK In essence, it is aimed at HTTP Requested one layer encapsulation , Because the server only provides REST Interface , So we take the specification , To get to know nacos Core interface of :
1、 Registration instance
1、 effect : Register the service address information to Nacos Server in
2、API:/nacos/v1/ns/instance (POST)
3、SDK:
void registerInstance(String serviceName , String ip , int port) throws NacosException; void registerInstance(String serviceName, String ip,int port,String clusterName) throws NacosException; void registerInstance(String serviceName,Instance instance) throws NacosException;4、 Explain :
serviceName: The service name , Equivalent to the configuration file spring.application.name
ip: Service instance ip
port: Service instance port
clusterName: Cluster name , Identify which cluster the current service instance belongs to
instance: Instance attributes , In fact, the above parameters are encapsulated into an object
5、 Call mode
NamingService naming=NamingFactory.createNamingService(System.getProperty("serveAddr")); naming.registerInstance("nacos_name","192.168.80.1",8080,"DEFAULT");
2、 Get all instances
1、 effect : According to the service name from Nacos Get the instance collection of all services on the registry
2、API: /nacos/v1/ns/instance/list (GET)
3、SDK:
List<Instance> getAllInstances(String serviceName) throws NacosException; List<Instance> getAllInstances(String serviceName,List<String> cluster) throws NacosException;4、 Explain :
serviceName: The service name
cluster: Cluster list , The input is one String aggregate
5、 Call mode :
NamingService naming=NamingFactory.createNamingService(System.getProperty("serveAddr")); System.out.println(naming.getAllInstances("nacos_name),true);
3、 Service monitoring
1、 effect : In order to make the client aware of the changes of the service provider instance in real time , amount to Eureka Heartbeat mechanism in
2、API:/nacos/v1/ns/instance/list (GET)
3、SDK:
void subscribe(String serviceName,EventListener listener) throws NacosException; void subscribe(String serviceName,List<String> clusters,EventListener listener) throw NacosException;4、 Explain :
EventListener: When an exception occurs in the provider service instance , For example, the upper and lower limits , An event callback will be called
There are two ways to monitor : The first one is : Client calls /nacos/v1/ns/instance/list Conduct scheduled polling
The second kind : be based on DatagramSocket Of UDP agreement , Realize the active push of the server
边栏推荐
- Pychart professional edition's solution to SQL script error reporting
- No assessment summary
- KVM hot migration for KVM virtual management
- Dup2 use
- Web site learning and sorting
- Solve the problem of garbled code in the MySQL execution SQL script database in docker (no need to rebuild the container)
- Unity game optimization (version 2) learning record 7
- Nonstandard compiler attribute extension
- Float type value range
- Understanding of speech signal framing
猜你喜欢

Mongodb Multi - field Aggregation group by

MySQL fuzzy query and sorting by matching degree

Understanding inode

行情绘图课程大纲1-基础知识

Float type value range
![[China & some provinces and cities] JSON file for offline map visualization](/img/ea/0c552e1e133f693b9902c54c2e09c8.jpg)
[China & some provinces and cities] JSON file for offline map visualization

Problems encountered in the use of PgSQL

About Evaluation Metrics

KVM virtualization management tool

Django uses redis to store sessions starting from 0
随机推荐
Case - random numbers without repetition (HashSet and TreeSet)
Mysql database crud operation
11 signalthrowingevent and signalboundaryevent of flowable signal event
One of PowerShell optimizations: prompt beautification
The 13th week of the second semester of sophomore year
Enhanced for loop
【线程/多线程】线程的执行顺序
Getclassloader() returns null, getclassloader() gets null
Modification and analysis of libcoap source code by Hongmeng device discovery module
18 flowable task manualtask and receivetask
[reprint] complete collection of C language memory and character operation functions
Introduction to R language 4--- R language process control
Unity game optimization (version 2) learning record 7
About Evaluation Metrics
Use the browser to cut the entire page (take chrome as an example)
Integer tips
MongoDB 多字段聚合Group by
Dup2 use
Quartz database storage
2021.9.30学习日志-postman