blob: be135b46457e4d2077bca80e27944a0cf3df6857 [file] [log] [blame]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="./sources/images/logo.ico">
<title>Dubbo</title>
<!-- Bootstrap core CSS -->
<link href="./sources/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<link href="./sources/bootstrap/assets/css/ie10-viewport-bug-workaround.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<!-- Custom styles for this template -->
<link href="carousel.css" rel="stylesheet">
<link href="./sources/awesome/font-awesome.min.css" rel="stylesheet">
<script src="https://use.fontawesome.com/4c7d1ecd7a.js"></script>
</head>
<!-- NAVBAR
================================================== -->
<body>
<div class="navbar-wrapper">
<div class="container">
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Dubbo Project</a>
</div>
<div id="navbar" style="float:right;" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Docs<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="user-guide/" target="_blank">User's Guide</a></li>
<li><a href="developer-guide/" target="_blank">Developer's Guide</a></li>
<li><a href="admin-guide/" target="_blank">Admin's Guide</a></li>
</ul>
</li>
<li><a href="#about">Releases</a></li>
<li><a href="#about">Community</a></li>
<li><a href="#contact">Q&A</a></li>
<!-- <li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li role="separator" class="divider"></li>
<li class="dropdown-header">Nav header</li>
<li><a href="#">Separated link</a></li>
<li><a href="#">One more separated link</a></li>
</ul>
</li>-->
</ul>
</div>
</div>
</nav>
</div>
</div>
<div class="jumbotron">
<div class="container">
<h1>Dubbo &nbsp;&nbsp;&nbsp;<a href="https://github.com/alibaba/dubbo"><i class="small fa fa-github"></i></a></h1>
<p>Dubbo is a distributed service framework enpowers applications with service import/export capability with high performance RPC.</p>
<p style="margin"><a class="btn btn-primary btn-lg" href="#quickstart" role="button">Quick Start &raquo;</a></p>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-sm-8 blog-main">
<div class="blog-post">
<p>Dubbo是一个分布式服务框架,致力于提供高性能和透明化的RPC远程服务调用方案,是阿里巴巴SOA服务化治理方案的核心框架,每天为**2,000+个服务提供3,000,000,000+**次访问量支持,并被广泛应用于阿里巴巴集团的各成员站点。</p>
<hr>
<h2 class="blog-post-title">Overview</h2>
<p>Dubbo是阿里巴巴SOA服务化治理方案的核心框架,每天为2,000+个服务提供3,000,000,000+次访问量支持,并被广泛应用于阿里巴巴集团的各成员站点:
</p>
<div style="margin:10px 0 10px 0;">
<img src="./sources/images/alibaba.png" class="img-rounded" style="margin:5px 5px 5px 0;">
<img src="./sources/images/1688.png" class="img-rounded" style="margin:5px 5px 5px 0;">
<img src="./sources/images/aliexpress.png" class="img-rounded" style="margin:5px 5px 5px 0;">
<img src="./sources/images/aliyun.png" class="img-rounded" style="margin:5px 5px 5px 0;">
<img src="./sources/images/aliloan.png" class="img-rounded" style="margin:5px 5px 5px 0;">
<img src="./sources/images/alibado.png" class="img-rounded" style="margin:5px 5px 5px 0;">
<img src="./sources/images/laiwang.png" class="img-rounded" style="margin:5px 5px 5px 0;">
<img src="./sources/images/lp.png" class="img-rounded" style="margin:5px 5px 5px 0;">
</div>
<p>自开源后,已有不少非阿里系公司在使用Dubbo,参见:<a href="#"></a>已知用户</p>
<br/>
<h4>那么,Dubbo是什么?</h4>
<p>Dubbo |ˈdʌbəʊ| 是一个分布式服务框架,致力于提供高性能和透明化的RPC远程服务调用方案,以及SOA服务治理方案。
其核心部分包含:
<ul class="list-group-item-heading">
<li>远程通讯: 提供对多种基于长连接的NIO框架抽象封装,包括多种线程模型,序列化,以及“请求-响应”模式的信息交换方式。</li>
<li>集群容错: 提供基于接口方法的透明远程过程调用,包括多协议支持,以及软负载均衡,失败容错,地址路由,动态配置等集群支持</li>
<li>自动发现: 基于注册中心目录服务,使服务消费方能动态的查找服务提供方,使地址透明,使服务提供方可以平滑增加或减少机器。</li>
</ul>
</p>
<br/>
<h4>Dubbo能做什么?</h4>
<ul class="list-group-item-heading">
<li>透明化的远程方法调用,就像调用本地方法一样调用远程方法,只需简单配置,没有任何API侵入。</li>
<li>软负载均衡及容错机制,可在内网替代F5等硬件负载均衡器,降低成本,减少单点。</li>
<li>服务自动注册与发现,不再需要写死服务提供方地址,注册中心基于接口名查询服务提供者的IP地址,并且能够平滑添加或删除服务提供者。</li>
</ul>
</div><!-- /.blog-post -->
<hr>
<!-- *****QUICK START****** -->
<div class="blog-post">
<h2 class="blog-post-title"><a name="quickstart">Quick Start</a></h2>
<p>This guide gets you started with dubbo with a simple working demo.</p>
<h4>Download the sources(demo)</h4>
<p>You’ll need a local copy of the example code to work through this quickstart. Download the demo code from our <a href="https://github.com/alibaba/dubbo/tree/master/dubbo-demo/" target="_blank">Github repository</a> (the following command clones the entire repository, but you just need the dubbo-demo for this quickstart and other tutorials):
</p>
<div>
<pre>
$ cd ~
$ # Clone the repository to get the source code.
$ git clone https://github.com/alibaba/dubbo.git dubbo
$ git checkout master
$ # or: git checkout -b dubbo-2.4.x-dev
</pre>
</div>
<h4>Download the sources(examples)</h4>
<p>1. Build the whole sources use the following maven command</p>
<div>
<pre>
$ cd ~/dubbo
$ mvn clean install -Dmaven.test.skip
$ # The demo code for this quickstart all stay in the `dubbo-demo` folder
$ cd ./dubbo-demo
$ ls
</pre>
</div>
<p>2. Run demo-provider. Start the provider and export service</p>
<div>
<pre>
$ # Navigate to the provider part
$ cd ~/dubbo/demo-demo/dubbo-demo-provider/target
$ # unpack
$ tar zxvf dubbo-demo-provider-2.5.4-SNAPSHOT-assembly.tar.gz
$ cd dubbo-demo-provider-2.5.4-SNAPSHOT/bin
$ ls
</pre>
</div>
<div>
<pre>
$ # Start the provider
$ ./start.sh
</pre>
</div>
<p>3. Run demo-consumer. Start the consumer and consume service provided by the provider above</p>
<div>
<pre>
$ # Navigate to the consumer part
$ cd ~/dubbo/demo-demo/dubbo-demo-consumer/target
$ # unpack
$ tar zxvf dubbo-demo-consumer-2.5.4-SNAPSHOT-assembly.tar.gz
$ cd dubbo-demo-consumer-2.5.4-SNAPSHOT/bin
$ ls
</pre>
</div>
<div>
<pre>
$ # Start the consumer
$ ./start.sh
</pre>
</div>
<hr>
<!-- ********Build this demo step by step****** -->
<h2>An explanation for Quick Start</h2>
<p>
下面,让我们从代码层面看一下Quick Start示例工程是如何实现的。<br/>
开始前请注意:
<ul class="list-group-item-heading">
<li>使用的是Dubbo推荐的<a href="user-guide/configuration/xml.html" target="_blank">Spring配置方式</a>。要使用API配置请参考<a href="user-guide/configuration/api.html">API配置</a></li>
<li>使用广播模式实现的服务自动注册与发现,生产环境中,一般要部署单独的<a href="user-guide/reference-registry/introduction.html" target="_blank">注册中心</a></li>
</ul>
</p>
<br/>
<h4>定义接口</h4>
<p>定义服务接口: (该接口需单独打包,在服务提供方和消费方共享)</p>
<pre>
package com.alibaba.dubbo.demo;
 
public interface DemoService {
 
    String sayHello(String name);
 
}
</pre>
<br/>
<h4>Provider实现</h4>
<p>服务提供方实现接口(对服务消费方隐藏实现):</p>
<pre>
package com.alibaba.dubbo.demo.provider;
import com.alibaba.dubbo.demo.DemoService;
public class DemoServiceImpl implements DemoService {
public String sayHello(String name) {
return "Hello " + name;
}
}
</pre>
<p>用Spring配置声明暴露服务:</p>
<pre>
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;
xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
xmlns:dubbo=&quot;http://code.alibabatech.com/schema/dubbo&quot;
xsi:schemaLocation=&quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd&quot;&gt;
&lt;!-- 提供方应用信息,用于计算依赖关系 --&gt;
&lt;dubbo:application name=&quot;hello-world-app&quot; /&gt;
&lt;!-- 使用multicast广播注册中心暴露服务地址 --&gt;
&lt;dubbo:registry address=&quot;multicast://224.5.6.7:1234&quot; /&gt;
&lt;!-- 用dubbo协议在20880端口暴露服务 --&gt;
&lt;dubbo:protocol name=&quot;dubbo&quot; port=&quot;20880&quot; /&gt;
&lt;!-- 声明需要暴露的服务接口 --&gt;
&lt;dubbo:service interface=&quot;com.alibaba.dubbo.demo.DemoService&quot; ref=&quot;demoService&quot; /&gt;
&lt;!-- 和本地bean一样实现服务 --&gt;
&lt;bean id=&quot;demoService&quot; class=&quot;com.alibaba.dubbo.demo.provider.DemoServiceImpl&quot; /&gt;
&lt;/beans&gt;
</pre>
<p>加载Spring配置:</p>
<pre>
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class Provider {
public static void main(String[] args) throws Exception {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"http://10.20.160.198/wiki/display/dubbo/provider.xml"});
context.start();
System.in.read(); // 按任意键退出
}
}
</pre>
<br/>
<h4>Consumer实现</h4>
<p>通过Spring配置引用远程服务:</p>
<pre>
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;
xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
xmlns:dubbo=&quot;http://code.alibabatech.com/schema/dubbo&quot;
xsi:schemaLocation=&quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd&quot;&gt;
&lt;!-- 消费方应用名,用于计算依赖关系,不是匹配条件,不要与提供方一样 --&gt;
&lt;dubbo:application name=&quot;consumer-of-helloworld-app&quot; /&gt;
&lt;!-- 使用multicast广播注册中心暴露发现服务地址 --&gt;
&lt;dubbo:registry address=&quot;multicast://224.5.6.7:1234&quot; /&gt;
&lt;!-- 生成远程服务代理,可以和本地bean一样使用demoService --&gt;
&lt;dubbo:reference id=&quot;demoService&quot; interface=&quot;com.alibaba.dubbo.demo.DemoService&quot; /&gt;
&lt;/beans&gt;
</pre>
<p>加载Spring配置,并调用远程服务:(也可以使用IoC注入)</p>
<pre>
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.alibaba.dubbo.demo.DemoService;
public class Consumer {
public static void main(String[] args) throws Exception {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"http://10.20.160.198/wiki/display/dubbo/consumer.xml"});
context.start();
DemoService demoService = (DemoService)context.getBean("demoService"); // 获取远程服务代理
String hello = demoService.sayHello("world"); // 执行远程方法
System.out.println( hello ); // 显示调用结果
}
}
</pre>
</div><!-- /.blog-post -->
</div><!-- /.blog-main -->
<div style="margin-left:30px;" class="col-sm-3 col-sm-offset-0 blog-sidebar">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Documentation</h3>
</div>
<div class="panel-body">
<ol class="list-unstyled">
<li><a href="user-guide/" target="_blank">User's Guide</a></li>
<li><a href="developer-guide/" target="_blank">Developer's Guide</a></li>
<li><a href="admin-guide/" target="_blank">Admin's Guide</a></li>
</ol>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Releases</h3>
</div>
<div class="panel-body">
Release Infos
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Others</h3>
</div>
<div class="panel-body">
</div>
</div>
</div><!-- /.blog-sidebar -->
</div><!-- /.row -->
<!-- FOOTER -->
<footer>
<p class="pull-right"><a href="#">Back to top</a></p>
<p>&copy; 2017 Alibaba Dubbo-teams</p>
</footer>
</div><!-- /.container -->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="./sources/bootstrap/assets/js/vendor/jquery.min.js"><\/script>')</script>
<script src="./sources/bootstrap/js/bootstrap.min.js"></script>
<!-- Just to make our placeholder images work. Don't actually copy the next line! -->
<script src="./sources/bootstrap/assets/js/vendor/holder.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="./sources/bootstrap/assets/js/ie10-viewport-bug-workaround.js"></script>
</body>
</html>