第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

深入淺出微服務(wù)框架dubbo(三):流程篇

標(biāo)簽:
Java
三、流程篇

画流程图为了记录debug过程,探究原理,而dubbo有各种扩展比如protocol有多种,注册中心也有多种选择,通信框架也有多种,不可能每个分支都覆盖到。所以只能选择自己比较熟悉使用比较多的来说明,力求讲清主线,熟悉了主线,就能举一反三熟悉支线了。容器选择spring,通信选择netty,注册中心选择zookeeper,zookeeper client选择curator,协议选择dubbo。

3.1 Provider启动
  • 准备工作
    以demoService为例,代码如下:
package com.alibaba.dubbo.demo;
public interface DemoService{
    String sayHello(String name);
}

public class DemoServiceImpl implements DemoService{
     public String sayHello(String name){
           System.out.println(RpcContext.getContext().getRemoteAddress());
           return"Hello "+ name +", response form provider:"+RpcContext.getContext().getLocalAddress();
     }
}

public class DemoProvider{
    public static void main(String[]args){
          com.alibaba.dubbo.container.Main.main(args);
    }
}

配置
dubbo.properties

dubbo.container=log4j,spring
dubbo.monitor.protocol=registry

dubbo-demo-provider.xml


<beansxmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">

    <beanid="demoService"class="com.alibaba.dubbo.demo.provider.DemoServiceImpl"/>  
    <dubbo:application name="demo-provider"owner="whf"/>
<dubbo:registry address="zookeeper://127.0.0.1:2181"transporter="curator"/>
    <dubbo:service interface="com.alibaba.dubbo.demo.DemoService"ref="demoService"protocol="dubbo"loadbalance="roundrobin"timeout=6000000/> 
    <dubbo:protocol name="dubbo"port="20880"heartbeat=600/> 
</beans>
  • 流程图

provider启动流程图
图片描述

3.2 consumer启动

代码清单1demoAction.java

Package com.alibaba.dubbo.demo.consumer;
Import com.alibaba.dubbo.demo.DemoService;
public class DemoAction{
   private DemoServicedemoService;
   public void setDemoService(DemoServicedemoService){
         this.demoService=demoService;
    }

    public void start()throws Exception {
       for(inti=0;i<Integer.MAX_VALUE;i++){
       try{
        String hello =demoService.sayHello("world"+i);
        System.out.println(hello);
        }catch(Exception e){
           e.printStackTrace();
        }
       Thread.sleep(2000);
          }
    }
}

配置清单1 dubbo.properties

dubbo.container=log4j,spring
dubbo.application.name=demo-consumer
dubbo.application.owner=whf
dubbo.registry.address=zookeeper://127.0.0.1:2181
dubbo.registry.transporter=curator
dubbo.protocol.serialization=hession2
dubbo.protocol.heartbeat=6000000
dubbo.reference.timeout=6000000
dubbo.monitor.protocol=registry

配置清单2 dubbo-demo-consumer.xml

<dubbo:reference id="demoService" interface="com.alibaba.dubbo.demo.DemoService"/>

consumer启动图

图片描述

3.3 服务处理流程图

图片描述

點擊查看更多內(nèi)容
7人點贊

若覺得本文不錯,就分享一下吧!

評論

作者其他優(yōu)質(zhì)文章

正在加載中
JAVA開發(fā)工程師
手記
粉絲
1.7萬
獲贊與收藏
1006

關(guān)注作者,訂閱最新文章

閱讀免費教程

感謝您的支持,我會繼續(xù)努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進(jìn)行掃碼打賞哦
今天注冊有機會得

100積分直接送

付費專欄免費學(xué)

大額優(yōu)惠券免費領(lǐng)

立即參與 放棄機會
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號

舉報

0/150
提交
取消