Dubbo应用

环境搭建

  1. zookeeper 下载安装(环境变量配置)
    1. 使用3.4.14版本https://archive.apache.org/dist/zookeeper/zookeeper-3.4.14/

项目搭建

项目模块

Dubbo-demo-provider
Dubbo-demo-consumer
Dubbo-demo-sdk
Maven 依赖

    
        2.12.0
    
        
        
            org.apache.zookeeper
            zookeeper
            3.4.7
        
        
        
            org.apache.dubbo
            dubbo
            2.7.3
        

        
            org.apache.curator
            curator-framework
            ${zookeeper.version}
        
        
            org.apache.curator
            curator-recipes
            ${zookeeper.version}
        

dubbo-admin(Dubbo控制台)

GitHub地址:https://github.com/apache/dubbo-admin

下载代码,执行 mvn clean package -Dmaven.test.skip=true

元数据出不来
解决办法:https://blog.csdn.net/wangxq0224/article/details/99304253

  1. 添加zk节点
    package com.yth.dubbo.provider.service.impl;
    import org.apache.curator.framework.CuratorFramework;
    import org.apache.curator.framework.CuratorFrameworkFactory;
    import org.apache.curator.retry.ExponentialBackoffRetry;
    public class Test {
        public static void main(String[] args) {
            try {
                CuratorFramework zkClient = CuratorFrameworkFactory.builder().
                        connectString("127.0.0.1:2181").
                        retryPolicy(new ExponentialBackoffRetry(1000, 3)).build();
                zkClient.start();
                if (zkClient.checkExists().forPath("/dubbo/config/dubbo/dubbo.properties") == null) {
                    zkClient.create().creatingParentsIfNeeded().forPath("/dubbo/config/dubbo/dubbo.properties");
                }
                zkClient.setData().forPath("/dubbo/config/dubbo/dubbo.properties", ("dubbo.registry.address=zookeeper://127.0.0.1:2181\n" +
                        "dubbo.metadata-report.address=zookeeper://127.0.0.1:2181").getBytes());
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    
    1. application.properties配置
      dubbo.registry.address=zookeeper://127.0.0.1:2181
      dubbo.metadata-report.address=zookeeper://127.0.0.1:2181
      

dubbo-monitor(监控中心)

用来统计服务的调⽤次数和调⽤时间的监控中⼼。
代码路径

dubbo 统一异常处理

你可能感兴趣的:(Dubbo应用)