Dubbo源码分析(三):Dubbo之服务端(Service)

dubbo源码分析之oneway&twoway请求 dubbo作为一个微服务治理框架,在RPC场景有着丰富的解决方案,我们在使用的使用要根据自己的需求使用对应的功能,做到按需选型、合理配置,避免过度设计或功能冗余。PS:技术、架构、设计方面的问题欢迎多多交流,爱交朋友,私信看到就回复。 阅读详情

    

    如上图所示的Dubbo的暴露服务的过程,不难看出它也和消费者端很像,也需要一个像reference的对象来维护service关联的所有对象及其属性,这里的reference就是provider。由于ServiceBean实现了



InitializingBean接口,所有在Spring实例化这个bean后会调用接口方法afterPropertiesSet:

public void afterPropertiesSet() throws Exception {
    	//如果没有配置provider
        if (getProvider() == null) {
        	//获取IOC容器里的所有provider
            Map<String, ProviderConfig> providerConfigMap = applicationContext == null ? null  : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, ProviderConfig.class, false, false);
            if (providerConfigMap != null && providerConfigMap.size() > 0) {
                Map<String, ProtocolConfig> protocolConfigMap = applicationContext == null ? null  : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, ProtocolConfig.class, false, false);
                if ((protocolConfigMap == null || protocolConfigMap.size() == 0)
                        && providerConfigMap.size() > 1) { // 兼容旧版本
                    List<ProviderConfig> providerConfigs = new ArrayList<ProviderConfig>();
                    for (ProviderConfig config : providerConfigMap.values()) {
                        if (config.isDefault() != null && config.isDefault().booleanValue()) {
                            providerConfigs.add(config);
                        }
                    }
                    //关联所有providers
                    if (providerConfigs.size() > 0) {
                        setProviders(providerConfigs);
                    }
                } else {
                    ProviderConfig providerConfig = null;
                    for (ProviderConfig config : providerConfigMap.values()) {
                        if (config.isDefault() == null || config.isDefault().booleanValue()) {
                            if (providerConfig != null) {
                                throw new IllegalStateException("Duplicate provider configs: " + providerConfig + " and " + config);
                            }
                            providerConfig = config;
                        }
                    }
                    if (providerConfig != null) {
                        setProvider(providerConfig);
                    }
                }
            }
        }
        //如果没有配置application,且没有配置provider
        if (getApplication() == null
                && (getProvider() == null || getProvider().getApplication() == null)) {
            //获取所有applications
        	Map<String, ApplicationConfig> applicationConfigMap = applicationContext == null ? null : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, ApplicationConfig.class, false, false);
            if (applicationConfigMap != null && applicationConfigMap.size() > 0) {
                ApplicationConfig applicationConfig = null;
                for (ApplicationConfig config : applicationConfigMap.values()) {
                    if (config.isDefault() == null || config.isDefault().booleanValue()) {
                        if (applicationConfig != null) {
                            throw new IllegalStateException("Duplicate application configs: " + applicationConfig + " and " + config);
                        }
                        applicationConfig = config;
                    }
                }
                //关联application
                if (applicationConfig != null) {
                    setApplication(applicationConfig);
                }
            }
        }
        //如果没有配置module,且没有配置provider
        if (getModule() == null
                && (getProvider() == null || getProvider().getModule() == null)) {
            Map<String, ModuleConfig> moduleConfigMap = applicationContext == null ? null : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, ModuleConfig.class, false, false);
            if (moduleConfigMap != null && moduleConfigMap.size() > 0) {
                ModuleConfig moduleConfig = null;
                for (ModuleConfig config : moduleConfigMap.values()) {
                    if (config.isDefault() == null || config.isDefault().booleanValue()) {
                        if (moduleConfig != null) {
                            throw new IllegalStateException("Duplicate module configs: " + moduleConfig + " and " + config);
                        }
                        moduleConfig = config;
                    }
                }
                //关联module
                if (moduleConfig != null) {
                    setModule(moduleConfig);
                }
            }
        }
        //如果没有配置registries,且没有配置provider
        if ((getRegistries() == null || getRegistries().size() == 0)
                && (getProvider() == null || getProvider().getRegistries() == null || getProvider().getRegistries().size() == 0)
                && (getApplication() == null || getApplication().getRegistries() == null || getApplication().getRegistries().size() == 0)) {
            Map<String, RegistryConfig> registryConfigMap = applicationContext == null ? null : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, RegistryConfig.class, false, false);
            if (registryConfigMap != null && registryConfigMap.size() > 0) {
                List<RegistryConfig> registryConfigs = new ArrayList<RegistryConfig>();
                for (RegistryConfig config : registryConfigMap.values()) {
                    if (config.isDefault() == null || config.isDefault().booleanValue()) {
                        registryConfigs.add(config);
                    }
                }
                //关联registries
                if (registryConfigs != null && registryConfigs.size() > 0) {
                    super.setRegistries(registryConfigs);
                }
            }
        }
        //如果没有配置monitor,且没有配置provider
        if (getMonitor() == null
                && (getProvider() == null || getProvider().getMonitor() == null)
                && (getApplication() == null || getApplication().getMonitor() == null)) {
            Map<String, MonitorConfig> monitorConfigMap = applicationContext == null ? null : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, MonitorConfig.class, false, false);
            if (monitorConfigMap != null && monitorConfigMap.size() > 0) {
                MonitorConfig monitorConfig = null;
                for (MonitorConfig config : monitorConfigMap.values()) {
                    if (config.isDefault() == null || config.isDefault().booleanValue()) {
                        if (monitorConfig != null) {
                            throw new IllegalStateException("Duplicate monitor configs: " + monitorConfig + " and " + config);
                        }
                        monitorConfig = config;
                    }
                }
                //关联monitor
                if (monitorConfig != null) {
                    setMonitor(monitorConfig);
                }
            }
        }
        //如果没有配置protocol,且没有配置provider
        if ((getProtocols() == null || getProtocols().size() == 0)
                && (getProvider() == null || getProvider().getProtocols() == null || getProvider().getProtocols().size() == 0)) {
            Map<String, ProtocolConfig> protocolConfigMap = applicationContext == null ? null  : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, ProtocolConfig.class, false, false);
            if (protocolConfigMap != null && protocolConfigMap.size() > 0) {
                List<ProtocolConfig> protocolConfigs = new ArrayList<ProtocolConfig>();
                for (ProtocolConfig config : protocolConfigMap.values()) {
                    if (config.isDefault() == null || config.isDefault().booleanValue()) {
                        protocolConfigs.add(config);
                    }
                }
                //关联protocol
                if (protocolConfigs != null && protocolConfigs.size() > 0) {
                    super.setProtocols(protocolConfigs);
                }
            }
        }
        //如果没有配置path
        if (getPath() == null || getPath().length() == 0) {
            if (beanName != null && beanName.length() > 0 
                    && getInterface() != null && getInterface().length() > 0
                    && beanName.startsWith(getInterface())) {
                setPath(beanName);
            }
        }
        //暴露provider
        if (! isDelay()) {
            export();
        }
    }

      Dubbo在确认了所有相关对象都配置后调用export方法开始暴露过程:

public synchronized void export() {
    	//如果provider没有配置
        if (provider != null) {
        	//如果exporter没有配置使用provider所关联的exporter
            if (export == null) {
                export = provider.getExport();
            }
            //如果delay(延迟暴露)没有配置,获取provider的delay
            if (delay == null) {
                delay = provider.getDelay();
            }
        }
        //如果不需要暴露接口则直接返回
        if (export != null && ! export.booleanValue()) {
            return;
        }
        //如果延迟暴露的时间(毫秒级)是存在的,开启线程并等待delay毫秒后开始暴露接口,否则直接执行暴露接口过程
        if (delay != null && delay > 0) {
            Thread thread = new Thread(new Runnable() {
                public void run() {
                    try {
                        Thread.sleep(delay);
                    } catch (Throwable e) {
                    }
                    doExport();
                }
            });
            thread.setDaemon(true);
            thread.setName("DelayExportServiceThread");
            thread.start();
        } else {
            doExport();
        }
    }
protected synchronized void doExport() {
    	//如果不需要暴露接口则抛出异常
        if (unexported) {
            throw new IllegalStateException("Already unexported!");
        }
        //如果已经暴露则不需要重复暴露
        if (exported) {
            return;
        }
        exported = true;
        //如果interfaceName没配置(这样dubbo就无法找到需要暴露的service对象)则抛出异常
        if (interfaceName == null || interfaceName.length() == 0) {
            throw new IllegalStateException("<dubbo:service interface=\"\" /> interface not allow null!");
        }
        checkDefault();
        //provider已经配置的情况下,如果application、module、registries、monitor、protocol中有未配置的均可以从provider获取
        if (provider != null) {
            if (application == null) {
                application = provider.getApplication();
            }
            if (module == null) {
                module = provider.getModule();
            }
            if (registries == null) {
                registries = provider.getRegistries();
            }
            if (monitor == null) {
                monitor = provider.getMonitor();
            }
            if (protocols == null) {
                protocols = provider.getProtocols();
            }
        }
        if (module != null) {
            if (registries == null) {
                registries = module.getRegistries();
            }
            if (monitor == null) {
                monitor = module.getMonitor();
            }
        }
        if (application != null) {
            if (registries == null) {
                registries = application.getRegistries();
            }
            if (monitor == null) {
                monitor = application.getMonitor();
            }
        }
        if (ref instanceof GenericService) {
            interfaceClass = GenericService.class;
            if (StringUtils.isEmpty(generic)) {
                generic = Boolean.TRUE.toString();
            }
        } else {
            try {
                interfaceClass = Class.forName(interfaceName, true, Thread.currentThread()
                        .getContextClassLoader());
            } catch (ClassNotFoundException e) {
                throw new IllegalStateException(e.getMessage(), e);
            }
            checkInterfaceAndMethods(interfaceClass, methods);
            checkRef();
            generic = Boolean.FALSE.toString();
        }
        //如果是本地服务
        if(local !=null){
        	//如果是本地服务在interfaceName属性后面加上Local
            if(local=="true"){
                local=interfaceName+"Local";
            }
            Class<?> localClass;
            try {
            	//加载service
                localClass = ClassHelper.forNameWithThreadContextClassLoader(local);
            } catch (ClassNotFoundException e) {
                throw new IllegalStateException(e.getMessage(), e);
            }
            if(!interfaceClass.isAssignableFrom(localClass)){
                throw new IllegalStateException("The local implemention class " + localClass.getName() + " not implement interface " + interfaceName);
            }
        }
        //如果是远程服务
        if(stub !=null){
            if(stub=="true"){
                stub=interfaceName+"Stub";
            }
            Class<?> stubClass;
            try {
            	//加载service
                stubClass = ClassHelper.forNameWithThreadContextClassLoader(stub);
            } catch (ClassNotFoundException e) {
                throw new IllegalStateException(e.getMessage(), e);
            }
            if(!interfaceClass.isAssignableFrom(stubClass)){
                throw new IllegalStateException("The stub implemention class " + stubClass.getName() + " not implement interface " + interfaceName);
            }
        }
        //检查application
        checkApplication();
        //检查registries
        checkRegistry();
        //检查protocol
        checkProtocol();
        //将所有这些对象的属性关联到provider
        appendProperties(this);
        checkStubAndMock(interfaceClass);
        if (path == null || path.length() == 0) {
            path = interfaceName;
        }
        //暴露地址
        doExportUrls();
    }
private void doExportUrls() {
    	//将注册的所有url匹配上对应的协议在服务端暴露出来
        List<URL> registryURLs = loadRegistries(true);
        for (ProtocolConfig protocolConfig : protocols) {
            doExportUrlsFor1Protocol(protocolConfig, registryURLs);
        }
    }
private void doExportUrlsFor1Protocol(ProtocolConfig protocolConfig, List<URL> registryURLs) {
        //如果没配置protocol则默认使用dubbo协议
    	String name = protocolConfig.getName();
        if (name == null || name.length() == 0) {
            name = "dubbo";
        }
        //获取主机地址
        String host = protocolConfig.getHost();
        if (provider != null && (host == null || host.length() == 0)) {
            host = provider.getHost();
        }
        boolean anyhost = false;
        if (NetUtils.isInvalidLocalHost(host)) {
            anyhost = true;
            try {
                host = InetAddress.getLocalHost().getHostAddress();
            } catch (UnknownHostException e) {
                logger.warn(e.getMessage(), e);
            }
            if (NetUtils.isInvalidLocalHost(host)) {
                if (registryURLs != null && registryURLs.size() > 0) {
                    for (URL registryURL : registryURLs) {
                        try {
                        	//创建socket,连接到注册中心
                            Socket socket = new Socket();
                            try {
                                SocketAddress addr = new InetSocketAddress(registryURL.getHost(), registryURL.getPort());
                                socket.connect(addr, 1000);
                                //获取服务所在主机地址
                                host = socket.getLocalAddress().getHostAddress();
                                break;
                            } finally {
                                try {
                                    socket.close();
                                } catch (Throwable e) {}
                            }
                        } catch (Exception e) {
                            logger.warn(e.getMessage(), e);
                        }
                    }
                }
                if (NetUtils.isInvalidLocalHost(host)) {
                    host = NetUtils.getLocalHost();
                }
            }
        }
        //获取协议接口号
        Integer port = protocolConfig.getPort();
        if (provider != null && (port == null || port == 0)) {
            port = provider.getPort();
        }
        final int defaultPort = ExtensionLoader.getExtensionLoader(Protocol.class).getExtension(name).getDefaultPort();
        if (port == null || port == 0) {
            port = defaultPort;
        }
        if (port == null || port <= 0) {
            port = getRandomPort(name);
            if (port == null || port < 0) {
                port = NetUtils.getAvailablePort(defaultPort);
                putRandomPort(name, port);
            }
            logger.warn("Use random available port(" + port + ") for protocol " + name);
        }

        //获取application、module、provider、protocol、exporter、registries、monitor所有属性
        Map<String, String> map = new HashMap<String, String>();
        if (anyhost) {
            map.put(Constants.ANYHOST_KEY, "true");
        }
        map.put(Constants.SIDE_KEY, Constants.PROVIDER_SIDE);
        map.put(Constants.DUBBO_VERSION_KEY, Version.getVersion());
        map.put(Constants.TIMESTAMP_KEY, String.valueOf(System.currentTimeMillis()));
        if (ConfigUtils.getPid() > 0) {
            map.put(Constants.PID_KEY, String.valueOf(ConfigUtils.getPid()));
        }
        appendParameters(map, application);
        appendParameters(map, module);
        appendParameters(map, provider, Constants.DEFAULT_KEY);
        appendParameters(map, protocolConfig);
        appendParameters(map, this);
        if (methods != null && methods.size() > 0) {
            for (MethodConfig method : methods) {
                appendParameters(map, method, method.getName());
                String retryKey = method.getName() + ".retry";
                if (map.containsKey(retryKey)) {
                    String retryValue = map.remove(retryKey);
                    if ("false".equals(retryValue)) {
                        map.put(method.getName() + ".retries", "0");
                    }
                }
                List<ArgumentConfig> arguments = method.getArguments();
                if (arguments != null && arguments.size() > 0) {
                    for (ArgumentConfig argument : arguments) {
                        //类型自动转换.
                        if(argument.getType() != null && argument.getType().length() >0){
                            Method[] methods = interfaceClass.getMethods();
                            //遍历所有方法
                            if(methods != null && methods.length > 0){
                                for (int i = 0; i < methods.length; i++) {
                                    String methodName = methods[i].getName();
                                    //匹配方法名称,获取方法签名.
                                    if(methodName.equals(method.getName())){
                                        Class<?>[] argtypes = methods[i].getParameterTypes();
                                        //一个方法中单个callback
                                        if (argument.getIndex() != -1 ){
                                            if (argtypes[argument.getIndex()].getName().equals(argument.getType())){
                                                appendParameters(map, argument, method.getName() + "." + argument.getIndex());
                                            }else {
                                                throw new IllegalArgumentException("argument config error : the index attribute and type attirbute not match :index :"+argument.getIndex() + ", type:" + argument.getType());
                                            }
                                        } else {
                                            //一个方法中多个callback
                                            for (int j = 0 ;j<argtypes.length ;j++) {
                                                Class<?> argclazz = argtypes[j];
                                                if (argclazz.getName().equals(argument.getType())){
                                                    appendParameters(map, argument, method.getName() + "." + j);
                                                    if (argument.getIndex() != -1 && argument.getIndex() != j){
                                                        throw new IllegalArgumentException("argument config error : the index attribute and type attirbute not match :index :"+argument.getIndex() + ", type:" + argument.getType());
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }else if(argument.getIndex() != -1){
                            appendParameters(map, argument, method.getName() + "." + argument.getIndex());
                        }else {
                            throw new IllegalArgumentException("argument config must set index or type attribute.eg: <dubbo:argument index='0' .../> or <dubbo:argument type=xxx .../>");
                        }

                    }
                }
            } // end of methods for
        }

        if (ProtocolUtils.isGeneric(generic)) {
            map.put("generic", generic);
            map.put("methods", Constants.ANY_VALUE);
        } else {
            String revision = Version.getVersion(interfaceClass, version);
            if (revision != null && revision.length() > 0) {
                map.put("revision", revision);
            }

            String[] methods = Wrapper.getWrapper(interfaceClass).getMethodNames();
            if(methods.length == 0) {
                logger.warn("NO method found in service interface " + interfaceClass.getName());
                map.put("methods", Constants.ANY_VALUE);
            }
            else {
                map.put("methods", StringUtils.join(new HashSet<String>(Arrays.asList(methods)), ","));
            }
        }
        if (! ConfigUtils.isEmpty(token)) {
            if (ConfigUtils.isDefault(token)) {
                map.put("token", UUID.randomUUID().toString());
            } else {
                map.put("token", token);
            }
        }
        if ("injvm".equals(protocolConfig.getName())) {
            protocolConfig.setRegister(false);
            map.put("notify", "false");
        }
        // 导出服务
        String contextPath = protocolConfig.getContextpath();
        if ((contextPath == null || contextPath.length() == 0) && provider != null) {
            contextPath = provider.getContextpath();
        }
        //创建服务所在url
        URL url = new URL(name, host, port, (contextPath == null || contextPath.length() == 0 ? "" : contextPath + "/") + path, map);

        if (ExtensionLoader.getExtensionLoader(ConfiguratorFactory.class)
                .hasExtension(url.getProtocol())) {
            url = ExtensionLoader.getExtensionLoader(ConfiguratorFactory.class)
                    .getExtension(url.getProtocol()).getConfigurator(url).configure(url);
        }

        String scope = url.getParameter(Constants.SCOPE_KEY);
        //配置为none不暴露
        if (! Constants.SCOPE_NONE.toString().equalsIgnoreCase(scope)) {

            //配置不是remote的情况下做本地暴露 (配置为remote,则表示只暴露远程服务)
            if (!Constants.SCOPE_REMOTE.toString().equalsIgnoreCase(scope)) {
            	//暴露的地址是localhost所以远端无法访问
                exportLocal(url);
            }
            //如果配置不是local则暴露为远程服务.(配置为local,则表示只暴露远程服务)
            if (! Constants.SCOPE_LOCAL.toString().equalsIgnoreCase(scope) ){
                if (logger.isInfoEnabled()) {
                    logger.info("Export dubbo service " + interfaceClass.getName() + " to url " + url);
                }
                if (registryURLs != null && registryURLs.size() > 0
                        && url.getParameter("register", true)) {
                    for (URL registryURL : registryURLs) {
                        url = url.addParameterIfAbsent("dynamic", registryURL.getParameter("dynamic"));
                        URL monitorUrl = loadMonitor(registryURL);
                        if (monitorUrl != null) {
                            url = url.addParameterAndEncoded(Constants.MONITOR_KEY, monitorUrl.toFullString());
                        }
                        if (logger.isInfoEnabled()) {
                            logger.info("Register dubbo service " + interfaceClass.getName() + " url " + url + " to registry " + registryURL);
                        }
                        //获取invoker
                        Invoker<?> invoker = proxyFactory.getInvoker(ref, (Class) interfaceClass, registryURL.addParameterAndEncoded(Constants.EXPORT_KEY, url.toFullString()));
                        //根据协议将invoker暴露成exporter,具体过程是创建一个ExchangeServer,它会绑定一个ServerSocket到配置端口
                        Exporter<?> exporter = protocol.export(invoker);
                        //将创建的exporter放进链表便于管理
                        exporters.add(exporter);
                    }
                } else {
                    Invoker<?> invoker = proxyFactory.getInvoker(ref, (Class) interfaceClass, url);

                    Exporter<?> exporter = protocol.export(invoker);
                    exporters.add(exporter);
                }
            }
        }
        this.urls.add(url);
    }

      整个暴露服务的流程就是首先检查配置是否完整然后获取协议和端口信息,通知registries自己已经注册可以提供服务最后创建Server绑定端口。这样用户就可以从配置的信息连接到Server并和Server通信远程调用方法了。





SAP-ABAP:新手入门篇——从0到1写出你的第一个ABAP Hello World程序并完成调试运行 本文是ABAP开发入门指南,详细介绍如何创建并运行第一个"Hello World"程序。主要内容包括:通过SE38事务码进入ABAP编辑器;创建以Z/Y开头的程序并保存为本地对象;编写简单的WRITE输出语句;完成语法检查、激活和执行流程;以及初步体验调试功能。文章特别强调ABAP开发的规范要求,如程序命名规则、激活与保存的区别等,并提供了详细的步骤说明和常见问题提示,帮助零基础开发者快速上手ABAP编程。 阅读详情

相关推荐

扣子工作流实战演练

例如,你可以在代码节点的输入中引用大模型节点的输出,这样代码节点就可以使用大模型节点的输出。扣子的工作流节点并不是固定的,而是由一系列可以任意添加的节点组成的,每个节点都有其特定的功能和用途。扣子工作流中常见的节点类型如图4-2所示。在图像生成节点中设置模型为人像,输入参数名为input,变量值引用开始节点的renwu,正向提示词为{{input}},如图4-19所示。然后添加两个节点,选择“图像生成”和“画板”,将“开始”节点、“图像生成”节点、“画板”节点、“结束”节点依次串联,如图4-17所示。

夏天又到了的专栏 1587

Dubbo学习之DubboService

Dubbo学习之DubboService 的简介。

我家有猫已长成的博客 1万+

Google OR-Tools的CP-SAT求解器,为什么比传统线性规划更适合你的组合优化问题?

本文深入解析Google OR-Tools中的CP-SAT求解器为何比传统线性规划更适合解决组合优化问题。CP-SAT融合约束规划与可满足性理论,原生支持复杂逻辑约束和离散决策,在物流、生产调度等领域展现出显著优势。通过技术对比和实战案例,展示CP-SAT在处理高组合复杂度问题时的卓越性能。

weixin_28700593的博客 925

dubbo服务详解

dubbo服务详解

晴天的博客 2951

模型性能评估之 Friedman 检验与 Nemenyi 后续检验

前言 当我们提出一种算法,需要知道我们的算法和现在已有的算法相比,性能是否更优的时候,就需要用到模型性能评估的方法。本篇博客介绍一种模型性能评估的方法:Friedman 检验与 Nemenyi 后续检验。 该方法的特点是:可以进行多个算法的比较。下面看看具体的使用: 具体使用 1. 计算序值 假定我们用 D1D_1D1​、D2D_2D2​ 、D3D_3D3​ 和 D4D_4D4​ 四个数据集对算法 AAA、BBB、CCC 进行比较。首先需要得到每个算法在每个数据集上的测试结果,可以是准确率,也可以是均方误差

蕾欧娜与26的博客 1万+

基于STM32环境温湿度监测系统设计

基于STM32环境温湿度监测系统设计1. 实验目的2. 任务和要求3. proteus仿真图4. 实验代码 1. 实验目的 (1) 掌握使用 KEIL MDK5 进行软件开发的具体流程; (2) 掌握硬件电路的设计方法; (3) 掌握 STM32 微控制器的程序设计及代码编写方法。 2. 任务和要求 (1)在 STM32F103 平台下,通过温度传感器 DS18B20 和湿度传感器 DHT11 实现环境温湿度信息的采集; (2)将温度传感器和湿度传感器所采集的数据在 LCD 液晶屏幕上显示出来,超

唯一的博客 2万+

深入理解@DubboReference与@DubboService【三】

本文旨在为读者提供对Apache Dubbo中`@DubboReference`和`@DubboService`注解的深入理解。我们将探讨这些注解的基本概念、使用方式以及它们在微服务架构中的重要性。通过具体实例和详细解释,本文将帮助读者掌握如何在Dubbo中有效使用这些注解,从而提高微服务的开发效率和运行性能。

todoitbo的博客 1万+

ZYNQ学习:PL端DDR3 读写测试

DDR SDRAM 的最大特点是双沿触发,即在时钟的上升沿和下降沿都能进行数据采集和发送,同样的工作时钟, DDR SDRAM 的读写速度可以比传统的 SDRAM 快一倍。本次实验使用的 DDR3 芯片是南亚的 NT5CC256M16ER-EKI, NT5CC256M16ER-EKI 的 bank 位宽为 3,行位宽为 15,列位宽为 10,所以它的地址大小等于 2^3*2^15*2^10(即 2^28=256M),数据位宽为 16bit,所以容量大小为 256M*16bit,也就是 512MByte。

shuidiQAQ的博客 3031

【转载】Dubbo注解@DubboService的机制

本次的文章的版本都是基于 2.7.7 版本的。 2.7.7提供了@EnableDubbo注解来用于和spring整合。 对于Import注解的源码的讲解,推荐看下这篇博客, 讲的十分清楚明白: https://blog.youkuaiyun.com/boling_cavalry/article/details/82530167 从Spring中 Dubbo的使用上面来看,有两个重要的注解,即@DubboService 和 @DubboReference。 对两个注解的解析分别在 ServiceAnnotationB

lyf_9580的博客 6143

SpringBoot3 + Vben5.0实战:从零搭建企业级管理后台(附完整代码)

本文详细介绍了如何从零开始,使用SpringBoot3与Vben5.0技术栈搭建现代化企业级管理后台。通过对比分析,阐述了该组合在开发效率、性能(如虚拟线程)和权限模型(RBAC)方面的优势,并提供了从项目初始化、核心功能开发到部署运维的完整实战指南,帮助开发者快速构建高性能、易维护的后台系统。

weixin_29306317的博客 171

【YOLO 系列】基于YOLO V8的智能车载交通标志识别系统【python源码+Pyqt5界面+数据集+训练代码】

本文详细介绍了基于YOLO V8构建智能车载交通标志识别系统的完整流程。从环境搭建、数据集准备、模型训练到PyQt5图形界面开发,提供了Python源码和实战代码,帮助开发者快速实现高精度、实时的交通标志检测应用,提升驾驶辅助系统的开发效率。

wdx012345的博客 966

dubbo分布式服务框架(高级特性篇)

本文详细介绍并实际操作dubbo常用高级特性,序列化、地址缓存、超时、重试、负载均衡、多版本、集群容错、服务降级

雪月清的博客 2064

PLC控制气缸与电磁阀:从原理到实战编程详解

在工业自动化领域,很多工程师都能编写PLC程序控制电机启停,但当涉及到气缸和电磁阀的精确控制时,却常常遇到动作不协调、响应延迟甚至设备损坏的问题。这背后的关键不在于PLC编程本身,而在于对气动元件特性和控制逻辑的深入理解。 本文将从实际工程问题出发,深入解析气缸与电磁阀的工作原理、PLC控制逻辑设计、常见故障排查方法,并通过完整的梯形图实例,帮助读者掌握气动系统自动化编程的核心要点。无论你是刚接触PLC的初学者,还是希望提升气动控制技能的工程师,都能从中获得实用的技术指导。 1. 气缸与电磁阀在自动化控制中

weixin_42522374的博客 337

Dubbo源码分析之ExtensionLoader源码分析

参考:http://dubbo.apache.org/zh-cn/docs/source_code_guide/dubbo-spi.html 上篇演示了dubbo spi 的一个小demo,这篇来看看源码,能力有限,不喜勿喷。 上篇的测试用例如下: @Test public void testExt2() throws Exception { ExtensionLoader<...

zhoujie的博客 482

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

3.Dubbo源码分析----Dubbo的Service注解分析

 前面已经对Dubbo跟Spring Boot的结合原理的分析了[https://www.jianshu.com/p/7048774803d5](Dubbo源码分析----Dubbo在Spring Boot启动时如何运行的),现在就是对前面几个注册的Bean进行分析  ServiceAnnotationBeanPostProcessor这个类用来处理Service标签的类。前面对于...

szhlcy的博客 1476

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

老版dubbo源码分析:dubbo[2]之dubbo杂点

dubbo 杂点 dubbo杂点,是dubbo源码分析系列的第二篇文章,该文描述的是一些的零散但很重要的知识,上一篇dubbo配置我们留的疑问我们也将在该篇文章中一一解答。 虽然名字叫做杂点,但也只是我实在找不到合适的词来概括这一篇文章的内容,总的来说,这里的知识点是相当重要的,这里将会引出一个jdk中存在的一个概念。 阅读该文的时候,读者应该尽量参考源码进行阅读。源码加上了相关的注释。 dubb...

codeL的博客 287

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

Dubbo源码分析(二)Dubbo服务发布Export

Dubbo源码分析(一)Dubbo的扩展点机制 Dubbo源码分析(二)Dubbo服务发布Export Dubbo源码分析(三)Dubbo的服务引用Refer Dubbo源码分析(四)Dubbo调用链-消费端(集群容错机制) Dubbo源码分析(五)Dubbo调用链-服务端 Dubbo源码分析(六)Dubbo通信的编码解码机制 Dubbo框架的设计细节 (未完,待续) 服务发布 打印的...

dhwkjr1467的博客 350

dubbo源码-Service注解

dubbo源码-Service注解前言源码分析总结 前言 上一篇已经详细分析了dubbo的配置解析,本小节我们聊聊@Service注解。 当你使用@Service注解时有没有疑惑,这不是spring自带的注解,dubbo是如何扫描到该注解的,扫描到后又做了什么处理。 源码分析 @EnableDubbo @EnableDubbo(scanBasePackages = “org.apache.dubbo.demo.provider”) @DubboComponentScan public @interface

LiuRenyou的博客 2941

深度解析 dubbo 服务调用异常:The service using threads greater than <dubbo:service executes=“128“ /> limited

背景介绍 服务在上线一段时间后,就出现了 Dubbo 调用异常,异常信息为: The service using threads greater than <dubbo:service executes=“128” /> limited。这样就导致功能不可用,由于该接口在实际中的并发量并不高,因此很诡异,在经过一段分析后,最终得以解决。 问题分析 dubbo:service executes=“128” 表示:服务提供者每服务每方法最大可并行执行请求数,可以通过 dubbo.provider.e

回归心灵的专栏 2736

dubbo spi 源码分析

文章目录java spi,dubbo spi测试源码分析ExtensionLoader入口createExtension创建拓展对象的过程getExtensionClasses获取所有的拓展类 java spi,dubbo spi Java SPI的缺点: 不支持按需加载,迭代器遍历会实例化所有的实现类,即使它没有被用到,太浪费资源了。 获取实现类的方式不灵活,只能通过迭代器遍历。 没有缓存,实现类会被多次创建。 扩展加载失败,失败原因丢失,不方便排查。 不支持AOP和IOC。 Dubbo SPI定义了

你就像甜甜的益达 1058

Dubbo注册dubbo服务的源码分析

在写代码之前先看一下dubbo的源码dubbo可以通过xml的方式或者注解的方式来配置注册到注册中心的服务下边先看看一xml的方式是怎么工作的,在dubbo的源码包目录下我们可以发现两个spring的文件,如下图↓ 让我们再看看最看是使用xml配置是的配置文件的头部部分,如下图↓ 当加载到这个配置文件的时候,就会加载到dubbo,再让我们看看spring.handlers这个文件,下边是

旺旺旺的博客 2400
上一篇: Dubbo源码分析(二):Dubbo之消费端(Consumer)
下一篇: Dubbo源码分析(四):Dubbo之Registry
闲庭细步
博客等级 码龄18年 304粉丝 86原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值