dubbo-admin支持spring-cloud-dubbo

洪俊拔
2023-12-01

支持spring-cloud-dubbo

具体项目代码

https://github.com/luoxiangxing/spring-cloud-dubbo-admin

一、修改的具体类
1、org.apache.dubbo.admin.service.RegistryServerSync
引入spring-cloud-dubbo的类
@Resource
private DubboServiceMetadataRepository dubboServiceMetadataRepository;
@Resource
private DubboMetadataServiceProxy dubboMetadataConfigServiceProxy;

2、修改点

//订阅spring-cloud-dubbo框架服务变更的事件SubscribedServicesChangedEvent
@EventListener(SubscribedServicesChangedEvent.class)
    public void start(SubscribedServicesChangedEvent event) throws Exception {
        Set<String> allServiceKeys = dubboServiceMetadataRepository.getSubscribedServices();
        log.info("订阅的所有服务:{}",allServiceKeys);
        for (String serviceName:allServiceKeys){
            try {
                boolean initialized = dubboMetadataConfigServiceProxy.isInitialized(serviceName);
                if(initialized){
                    DubboMetadataService proxy = dubboMetadataConfigServiceProxy.getProxy(serviceName);
                    Map<String, String> allExportedURLs = proxy.getAllExportedURLs();
                    if(allExportedURLs !=null && !allExportedURLs.isEmpty()){
                        allExportedURLs.forEach((key,value)->{
                            List<URL> urlList = jsonUtils.toURLs(value);
                            cacheURL(urlList);
                        });
                        //log.info("所有导出的接口:{}",allExportedURLs);
                    }
                }
            }catch (Exception e){
                log.error("获取服务暴露的URL出错,服务名:{}",serviceName);
            }

        }
    }

3、修改了redis密码登陆的问题,修改了dubbo-metadata-report-redis的密码登陆,具体已经重新打包,放在项目的meta-jar下了

 类似资料: