欢迎您访问365答案网,请分享给你的朋友!
生活常识 学习资料

SpringCloud源码学习

时间:2023-07-26

Nacos 设计模型

nameSpace->group->Service/DataId

 Nacos 服务领域模型

 

 

@Autowired private LoadBalancerClient loadBalancerClient; @Autowired private RestTemplate restTemplate; //获取服务实例,使用负载均衡客户端根据服务名选择实例 ServiceInstance serviceInstance = loadBalancerClient.choose("dubbo-provider"); URI uri = serviceInstance.getUri(); //ip+端口号 restTemplate.getForObject(uri+"/student/list",String.class); //参数详情{"host":"2.0.3.92","instanceId":"2.0.3.92:20880","metadata":{"dubbo.metadata-service.urls":"[ "dubbo://2.0.3.92:20880/com.alibaba.cloud.dubbo.service.DubbometadataService?anyhost=true&application=dubbo-provider&bind.ip=2.0.3.92&bind.port=20880&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&group=dubbo-provider&interface=com.alibaba.cloud.dubbo.service.DubbometadataService&metadata-type=remote&methods=getAllServiceKeys,getServiceRestmetadata,getExportedURLs,getAllExportedURLs&pid=39176&qos.enable=false&release=2.7.8&revision=2.2.2.RELEASE&side=provider×tamp=1644200749402&version=1.0.0" ]","preserved.register.source":"SPRING_CLOUD","dubbo.protocols.dubbo.port":"20880"},"port":20880,"secure":false,"server":{"alive":true,"host":"2.0.3.92","hostPort":"2.0.3.92:20880","id":"2.0.3.92:20880","instance":{"clusterName":"DEFAULT","enabled":true,"ephemeral":true,"healthy":true,"instanceHeartBeatInterval":5000,"instanceHeartBeatTimeOut":15000,"instanceId":"2.0.3.92#20880#DEFAULT#DEFAULT_GROUP@@dubbo-provider","ip":"2.0.3.92","ipDeleteTimeout":30000,"metadata":{"$ref":"$.metadata"},"port":20880,"serviceName":"DEFAULT_GROUP@@dubbo-provider","weight":1.0},"metaInfo":{"appName":"DEFAULT_GROUP@@dubbo-provider","instanceId":"2.0.3.92#20880#DEFAULT#DEFAULT_GROUP@@dubbo-provider"},"metadata":{"$ref":"$.metadata"},"port":20880,"readyToServe":true,"zone":"UNKNOWN"},"serviceId":"dubbo-provider","uri":"http://2.0.3.92:20880"}

Copyright © 2016-2020 www.365daan.com All Rights Reserved. 365答案网 版权所有 备案号:

部分内容来自互联网,版权归原作者所有,如有冒犯请联系我们,我们将在三个工作时内妥善处理。