当前位置:网站首页>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
边栏推荐
- Initial redis experience
- Windbos run command set
- Windbos common CMD (DOS) command set
- Wampserver (MySQL) installation
- 行情绘图课程大纲1-基础知识
- Unity游戏优化(第2版)学习记录7
- 15 inclusivegateway and eventgateway of flowable gateway
- Input a number and output each digit from high to low
- MongoDB 多字段聚合Group by
- Create a harbor image library from the command line
猜你喜欢
System file interface open
MySQL transactions and foreign keys
Pychart error resolution: process finished with exit code -1073741819 (0xc0000005)
A simple recursion problem of linked list
Customer information management system - C language
Mongodb Multi - field Aggregation group by
Case - the list set stores student objects and traverses them in three ways
powershell优化之一:提示符美化
Pycharm错误解决:Process finished with exit code -1073741819 (0xC0000005)
Hainan University Postgraduate Entrance Examination electronic information (085400) landing experience
随机推荐
[China & some provinces and cities] JSON file for offline map visualization
Error: unmapped character encoding GBK
How to set the import / export template to global text format according to the framework = (solve the problem of scientific counting)
mongo
Install harbor (online offline)
Case - random numbers without repetition (HashSet and TreeSet)
9. Errorstartevent and errorboundaryevent of error events
Use of mongodb
MySQL built-in functions
Integer tips
Set the correct width and height of the custom dialog
Bicolor case
[reprint] complete collection of C language memory and character operation functions
12 error end event and terminateendevent of end event
One of PowerShell optimizations: prompt beautification
Fast power code
Violence enumeration~
How to Algorithm Evaluation Methods
Current limiting and fusing of gateway gateway in Spirng cloud
2 first experience of drools