ダボの使用と原則

何ダボこと?

ダボは、コアフレームワークアリババSOAサービスのガバナンスプログラム、毎日の訪問3,000,000,000+ 2,000+つのサービスに対するサポートの量であり、広く様々な会員サイトアリババグループで使用されています。
ダボは[]である 分散型サービスフレームワーク を提供することを約束された、 高性能とRPCリモートサービスコールプログラム、サービスおよびSOAガバナンスプログラムの透明性を

コア部は、:
  • リモート通信: - 情報交換「要求 - 応答」モードフレームベースのNIOパッケージ長抽象接続モデルの様々な提供は、複数のスレッド、シリアライゼーション、およびを含みます。
  • クラスタ・トレラント・フォルト透明インタフェースメソッドを提供するマルチプロトコルサポートを含むリモートプロシージャコール、ならびにソフト負荷分散、フォールトトレランス障害、アドレスルーティング、動的な構成および他のクラスタのサポートに基づいています。
  • 自動検出:レジストリベースのディレクトリサービス、サービスは、動的検索サービスプロバイダを消費することができるサービスプロバイダがスムーズにマシンを増減できるように、アドレスは、透明です。

ダボは何ですか?

  • 透明リモートメソッド呼び出し、任意の侵入APIなしで、ローカルメソッド呼び出しリモートメソッドだけの簡単な設定を呼び出すのと同じ。
  • ネットワークなどのソフト負荷分散とフォールトトレランスのメカニズムは、F5ハードウェアロードバランサを置き換え、低コスト、単一ポイントを減らすことができます。
  • 自動登録とサービスの発見、もはや死んサービスプロバイダアドレス、IPアドレス、レジストリベースのクエリインタフェース名サービスプロバイダを記述する必要がなく、スムーズにサービスプロバイダを追加または削除することができます。

春の統合

フルダボ、透過的なアクセス・アプリケーション、アプリケーションなし侵入APIと春の配置は、構成が単純に春ダボ、ダボスプリング式の拡張スキーマをロードすることができます。

ダボの概念の一部に上記の簡単な紹介、ここで下の画像を説明するための図を与える: 

我々は、この画像を記述するために使用することは、その後、プロジェクトにマッピングされた:
       我々は、このようなシステムのような複数のTomcatの異なるシステムを展開する場合(TomcatA)は、サービス中のBシステム(TomcatB)を呼び出したい場合、ダボが場に出ます。
       まず、我々は、レジストリ内のBシステムは、URLがで登録し、その後、レジストリに返さ所有する必要があるすべてのAは、その後、システムが呼び出すことができるシステムをURLます。
  もちろん、私はここに言った、このプロジェクトで使用ダボの一つだけ使用であるダボリモート関数呼び出しです。(そして、実際にWebサービスのようなビットを感じる)

プロジェクトでダボユースケースを見て、ここで質問に来て:
で飼育係をインストールするLinuxの1、
この場所は、Linux上でボーエンの前に設置詳細飼育係に概説されていないが、直接ここに開始飼育係の後にインストール、Linuxソフトウェアがインストールされている中での話されています。


2は、必要と
我々が必要としているとき、私たちが行うにはいくつかの運動を行うには、商品(製品)の背景(コンソール)を必要とし、ここで我々は唯一のサービスコールで製品を達成するためにどのようにして、公共サービスのメソッドを使用することができ、ここで?それは 
プロジェクト構造:

公共サービスメソッド:
TestTbService.java:

复制代码
1つのパッケージcn.itcast.core.service。
2 
3インポートcn.itcast.core.bean.TestTb。
4 
5パブリックインターフェイスTestTbService { 
6公共ボイドinsertTestTb(TestTb testTb)。
7 }
复制代码





サービス実装クラスの製品:
TestTbService.java:

复制代码
 1 package cn.itcast.core.service;
 2 
 3 import org.springframework.beans.factory.annotation.Autowired;
 4 import org.springframework.stereotype.Service;
 5 import org.springframework.transaction.annotation.Transactional;
 6 
 7 import cn.itcast.core.bean.TestTb;
 8 import cn.itcast.core.dao.TestTbDao;
 9 
10 @Service("testTbService")
11 @Transactional
12 public class TestTbServiceImpl implements TestTbService {
13 
14     @Autowired
15     private TestTbDao testTbDao;
16     
17     //保存
18     public void insertTestTb(TestTb testTb){
19         testTbDao.insertTestTb(testTb);
20     }
21 }
复制代码



在console中使用product中的service实现类:
CenterController.java:

复制代码
 1 package cn.itcast.core.controller;
 2 
 3 import java.util.Date;
 4 
 5 import org.junit.runners.model.TestTimedOutException;
 6 import org.springframework.beans.factory.annotation.Autowired;
 7 import org.springframework.stereotype.Controller;
 8 import org.springframework.ui.Model;
 9 import org.springframework.web.bind.annotation.RequestMapping;
10 
11 import cn.itcast.core.bean.TestTb;
12 import cn.itcast.core.service.TestTbService;
13 
14 @Controller
15 public class CenterController {
16     
17     @Autowired
18     private TestTbService testTbService;
19     
20     //测试
21     @RequestMapping(value = "/test/index.do")
22     public void index(Model model){
23         
24         TestTb testTb = new TestTb();
25         testTb.setName("范冰冰");
26         testTb.setBirthday(new Date());
27         
28         testTbService.insertTestTb(testTb);
29         
30     }
31 }
复制代码

 

如果这样直接调用能够行的通吗?  当然是不行的, 在console里面定义的只是service方法, 那么这里是怎么直接调用到了product中的service实现类呢?

当然了, 这里就需要一些配置文件了:    首先是需要在product中注册服务:   dubbo-provider.xml:

复制代码
 1 <beans xmlns="http://www.springframework.org/schema/beans"
 2     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
 3     xmlns:context="http://www.springframework.org/schema/context"
 4     xmlns:aop="http://www.springframework.org/schema/aop" 
 5     xmlns:tx="http://www.springframework.org/schema/tx"
 6     xmlns:task="http://www.springframework.org/schema/task"
 7     xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
 8     xsi:schemaLocation="http://www.springframework.org/schema/beans 
 9         http://www.springframework.org/schema/beans/spring-beans-4.0.xsd 
10         http://www.springframework.org/schema/mvc 
11         http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd 
12         http://www.springframework.org/schema/context 
13         http://www.springframework.org/schema/context/spring-context-4.0.xsd 
14         http://www.springframework.org/schema/aop 
15         http://www.springframework.org/schema/aop/spring-aop-4.0.xsd 
16         http://www.springframework.org/schema/tx 
17         http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
18         http://www.springframework.org/schema/task
19            http://www.springframework.org/schema/task/spring-task-4.0.xsd
20         http://code.alibabatech.com/schema/dubbo        
21         http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
22         
23         
24         <!-- 整合Dubbo -->
25         <!-- 第一步:Dubbo起名称    计算用此名称来区分   -->
26         <dubbo:application name="babasport-service-product"/>
27         <!-- 第二步:中介  注册中心: zookeeper  redis ... -->
28         <!-- <dubbo:registry address="192.168.200.128:2181,192.168.200.129:2181,192.168.200.130:2181" protocol="zookeeper"/> -->
29         <dubbo:registry address="192.168.200.128:2181" protocol="zookeeper"/>
30         <!-- 第三步:设置dubbo的端口号     192.168.40.88:20880/接口  -->
31         <dubbo:protocol name="dubbo" port="20880"/>
32         <!-- 第四步:设置服务提供方 提供的接口 -->
33         <dubbo:service interface="cn.itcast.core.service.TestTbService" ref="testTbService"/>
34         
35 </beans>
复制代码

接下来就是在console中使用了:   服务消费方:    dubbo-cusmer.xml:

复制代码
 1 <beans xmlns="http://www.springframework.org/schema/beans"
 2     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
 3     xmlns:context="http://www.springframework.org/schema/context"
 4     xmlns:aop="http://www.springframework.org/schema/aop" 
 5     xmlns:tx="http://www.springframework.org/schema/tx"
 6     xmlns:task="http://www.springframework.org/schema/task"
 7     xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
 8     xsi:schemaLocation="http://www.springframework.org/schema/beans 
 9         http://www.springframework.org/schema/beans/spring-beans-4.0.xsd 
10         http://www.springframework.org/schema/mvc 
11         http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd 
12         http://www.springframework.org/schema/context 
13         http://www.springframework.org/schema/context/spring-context-4.0.xsd 
14         http://www.springframework.org/schema/aop 
15         http://www.springframework.org/schema/aop/spring-aop-4.0.xsd 
16         http://www.springframework.org/schema/tx 
17         http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
18         http://www.springframework.org/schema/task
19            http://www.springframework.org/schema/task/spring-task-4.0.xsd
20         http://code.alibabatech.com/schema/dubbo        
21         http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
22         
23         <!-- 整合Dubbo -->
24         <!-- 第一步:Dubbo起名称    计算用此名称来区分   -->
25         <dubbo:application name="babasport-console"/>
26         <!-- 第二步:中介  注册中心    zookeeper  redis ... -->
27         <!--<dubbo:registry address="192.168.200.128:2181,192.168.200.129:2181,192.168.200.130:2181" protocol="zookeeper"/> -->
28         <dubbo:registry address="192.168.200.128:2181" protocol="zookeeper"/>
29         <!-- 第三步:调用服务提供方 提供的接口 -->
30         <dubbo:reference interface="cn.itcast.core.service.TestTbService" id="testTbService"/>
31         
32 </beans>
复制代码



剩下的就是启动服务了:
注意先启动服务提供方, 然后再启动服务消费方.

 

 转:https://www.cnblogs.com/wang-meng/p/5791598.html

 

おすすめ

転載: www.cnblogs.com/651434092qq/p/11592285.html