README.md 11.0 KB
Newer Older
N
nzomkxia 已提交
1
# Apache Dubbo (incubating) Project
I
Ian Luo 已提交
2

H
Huxing Zhang 已提交
3 4
[![Build Status](https://travis-ci.org/apache/incubator-dubbo.svg?branch=master)](https://travis-ci.org/apache/incubator-dubbo)
[![codecov](https://codecov.io/gh/apache/incubator-dubbo/branch/master/graph/badge.svg)](https://codecov.io/gh/apache/incubator-dubbo)
H
Huxing Zhang 已提交
5
![maven](https://img.shields.io/maven-central/v/org.apache.dubbo/dubbo.svg)
I
Ian Luo 已提交
6 7 8
![license](https://img.shields.io/github/license/alibaba/dubbo.svg)
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/apache/incubator-dubbo.svg)](http://isitmaintained.com/project/apache/incubator-dubbo "Average time to resolve an issue")
[![Percentage of issues still open](http://isitmaintained.com/badge/open/apache/incubator-dubbo.svg)](http://isitmaintained.com/project/apache/incubator-dubbo "Percentage of issues still open")
H
Huxing Zhang 已提交
9
[![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Apache%20Dubbo%20(incubating)%20is%20a%20high-performance%2C%20java%20based%2C%20open%20source%20RPC%20framework.&url=http://dubbo.incubator.apache.org/&via=ApacheDubbo&hashtags=rpc,java,dubbo,micro-service)
X
Xin Wang 已提交
10
[![](https://img.shields.io/twitter/follow/ApacheDubbo.svg?label=Follow&style=social&logoWidth=0)](https://twitter.com/intent/follow?screen_name=ApacheDubbo)
I
Ian Luo 已提交
11
[![Gitter](https://badges.gitter.im/alibaba/dubbo.svg)](https://gitter.im/alibaba/dubbo?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
H
Huxing Zhang 已提交
12

S
Song Kun 已提交
13
Apache Dubbo (incubating) is a high-performance, Java based open source RPC framework. Please visit [official site](http://dubbo.incubator.apache.org) for quick start and documentations, as well as [Wiki](https://github.com/apache/incubator-dubbo/wiki) for news, FAQ, and release notes.
I
Ian Luo 已提交
14

S
Song Kun 已提交
15
We are now collecting dubbo user info in order to help us to improve Dubbo better, pls. kindly help us by providing yours on [issue#1012: Wanted: who's using dubbo](https://github.com/apache/incubator-dubbo/issues/1012), thanks :)
I
Ian Luo 已提交
16

H
Huxing Zhang 已提交
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
## Architecture

![Architecture](http://dubbo.apache.org/img/architecture.png)

## Features

* Transparent interface based RPC
* Intelligent load balancing
* Automatic service registration and discovery
* High extensibility
* Runtime traffic routing
* Visualized service governance

## Getting started

S
Song Kun 已提交
32
The following code snippet comes from [Dubbo Samples](https://github.com/apache/incubator-dubbo-samples/tree/master/dubbo-samples-api). You may clone the sample project and step into `dubbo-samples-api` sub directory before read on.
I
Ian Luo 已提交
33 34

```bash
S
Song Kun 已提交
35 36
# git clone https://github.com/apache/incubator-dubbo-samples.git
# cd incubator-dubbo-samples/dubbo-samples-api
I
Ian Luo 已提交
37 38
```

S
Song Kun 已提交
39
There's a [README](https://github.com/apache/incubator-dubbo-samples/tree/master/dubbo-samples-api/README.md) file under `dubbo-samples-api` directory. Read it and try this sample out by following the instructions.
I
Ian Luo 已提交
40

H
Huxing Zhang 已提交
41 42 43
### Maven dependency

```xml
I
Ian Luo 已提交
44
<properties>
45
    <dubbo.version>2.7.0</dubbo.version>
I
Ian Luo 已提交
46 47 48 49 50
</properties>
    
<dependencyManagement>
    <dependencies>
        <dependency>
51
            <groupId>org.apache.dubbo</groupId>
I
Ian Luo 已提交
52 53 54 55 56 57 58 59 60 61
            <artifactId>dubbo-dependencies-bom</artifactId>
            <version>${dubbo.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
62
        <groupId>org.apache.dubbo</groupId>
63
        <artifactId>dubbo</artifactId>
I
Ian Luo 已提交
64 65 66 67 68 69
        <version>${dubbo.version}</version>
    </dependency>
    <dependency>
        <groupId>io.netty</groupId>
        <artifactId>netty-all</artifactId>
    </dependency>
70 71 72 73 74 75 76 77 78 79 80 81
    <dependency>
        <groupId>org.apache.curator</groupId>
        <artifactId>curator-framework</artifactId>
    </dependency>
    <dependency>
        <groupId>org.apache.curator</groupId>
        <artifactId>curator-recipes</artifactId>
    </dependency>
    <dependency>
        <groupId>org.apache.zookeeper</groupId>
        <artifactId>zookeeper</artifactId>
    </dependency>
I
Ian Luo 已提交
82
</dependencies>
H
Huxing Zhang 已提交
83 84
```

I
Ian Luo 已提交
85
### Define service interfaces
H
Huxing Zhang 已提交
86 87

```java
蓝大巨's avatar
蓝大巨 已提交
88
package org.apache.dubbo.samples.api;
H
Huxing Zhang 已提交
89

90
public interface GreetingService {
H
Huxing Zhang 已提交
91 92 93 94
    String sayHello(String name);
}
```

S
Song Kun 已提交
95
*See [api/GreetingService.java](https://github.com/apache/incubator-dubbo-samples/blob/master/dubbo-samples-api/src/main/java/org/apache/dubbo/samples/api/GreetingsService.java) on GitHub.*
I
Ian Luo 已提交
96 97

### Implement service interface for the provider
H
Huxing Zhang 已提交
98 99

```java
蓝大巨's avatar
蓝大巨 已提交
100
package org.apache.dubbo.samples.provider;
H
Huxing Zhang 已提交
101
 
蓝大巨's avatar
蓝大巨 已提交
102
import org.apache.dubbo.samples.api.GreetingService;
H
Huxing Zhang 已提交
103
 
104
public class GreetingServiceImpl implements GreetingService {
H
Huxing Zhang 已提交
105 106 107 108 109 110
    public String sayHello(String name) {
        return "Hello " + name;
    }
}
```

S
Song Kun 已提交
111
*See [provider/GreetingServiceImpl.java](https://github.com/apache/incubator-dubbo-samples/blob/master/dubbo-samples-api/src/main/java/org/apache/dubbo/samples/provider/GreetingsServiceImpl.java) on GitHub.*
I
Ian Luo 已提交
112 113

### Start service provider
H
Huxing Zhang 已提交
114 115 116 117

```java
package org.apache.dubbo.demo.provider;

118 119 120
import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.ServiceConfig;
蓝大巨's avatar
蓝大巨 已提交
121
import org.apache.dubbo.samples.api.GreetingService;
H
Huxing Zhang 已提交
122 123 124

import java.io.IOException;
 
I
Ian Luo 已提交
125
public class Application {
H
Huxing Zhang 已提交
126 127 128 129 130 131 132 133 134 135 136 137

    public static void main(String[] args) throws IOException {
        ServiceConfig<GreetingService> serviceConfig = new ServiceConfig<GreetingService>();
        serviceConfig.setApplication(new ApplicationConfig("first-dubbo-provider"));
        serviceConfig.setRegistry(new RegistryConfig("multicast://224.5.6.7:1234"));
        serviceConfig.setInterface(GreetingService.class);
        serviceConfig.setRef(new GreetingServiceImpl());
        serviceConfig.export();
        System.in.read();
    }
}
```
I
Ian Luo 已提交
138

S
Song Kun 已提交
139
*See [provider/Application.java](https://github.com/apache/incubator-dubbo-samples/blob/master/dubbo-samples-api/src/main/java/org/apache/dubbo/samples/provider/Application.java) on GitHub.*
I
Ian Luo 已提交
140 141 142 143 144 145 146 147

### Build and run the provider

```bash
# mvn clean package
# mvn -Djava.net.preferIPv4Stack=true -Dexec.mainClass=org.apache.dubbo.demo.provider.Application exec:java
```

H
Huxing Zhang 已提交
148 149 150 151 152
### Call remote service in consumer

```java
package org.apache.dubbo.demo.consumer;

153 154 155
import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.ReferenceConfig;
import org.apache.dubbo.config.RegistryConfig;
蓝大巨's avatar
蓝大巨 已提交
156
import org.apache.dubbo.samples.api.GreetingService;
H
Huxing Zhang 已提交
157

I
Ian Luo 已提交
158
public class Application {
H
Huxing Zhang 已提交
159 160 161 162 163 164 165 166 167 168 169
    public static void main(String[] args) {
        ReferenceConfig<GreetingService> referenceConfig = new ReferenceConfig<GreetingService>();
        referenceConfig.setApplication(new ApplicationConfig("first-dubbo-consumer"));
        referenceConfig.setRegistry(new RegistryConfig("multicast://224.5.6.7:1234"));
        referenceConfig.setInterface(GreetingService.class);
        GreetingService greetingService = referenceConfig.get();
        System.out.println(greetingService.sayHello("world"));
    }
}
```

I
Ian Luo 已提交
170 171 172 173 174 175 176 177 178
### Build and run the consumer

```bash
# mvn clean package
# mvn -Djava.net.preferIPv4Stack=true -Dexec.mainClass=org.apache.dubbo.demo.consumer.Application exec:java
```

The consumer will print out `Hello world` on the screen.

S
Song Kun 已提交
179
*See [consumer/Application.java](https://github.com/apache/incubator-dubbo-samples/blob/master/dubbo-samples-api/src/main/java/org/apache/dubbo/samples/consumer/Application.java) on GitHub.*
I
Ian Luo 已提交
180

H
Huxing Zhang 已提交
181
### Next steps
I
Ian Luo 已提交
182

I
Ian Luo 已提交
183
* [Your first Dubbo application](http://dubbo.apache.org/en-us/blog/dubbo-101.html) - A 101 tutorial to reveal more details, with the same code above.
184
* [Dubbo user manual](http://dubbo.apache.org/en-us/docs/user/preface/background.html) - How to use Dubbo and all its features.
0
0xflotus 已提交
185
* [Dubbo developer guide](http://dubbo.apache.org/en-us/docs/dev/build.html) - How to involve in Dubbo development.
186
* [Dubbo admin manual](http://dubbo.apache.org/en-us/docs/admin/install/provider-demo.html) - How to admin and manage Dubbo services.
187

H
Huxing Zhang 已提交
188 189
## Contact

H
Huxing Zhang 已提交
190
* Mailing list: 
S
Song Kun 已提交
191
  * dev list: for dev/user discussion. [subscribe](mailto:dev-subscribe@dubbo.incubator.apache.org), [unsubscribe](mailto:dev-unsubscribe@dubbo.incubator.apache.org), [archive](https://lists.apache.org/list.html?dev@dubbo.apache.org),  [guide](https://github.com/apache/incubator-dubbo/wiki/Mailing-list-subscription-guide)
H
Huxing Zhang 已提交
192
  
H
Huxing Zhang 已提交
193 194 195 196 197 198 199 200
* Bugs: [Issues](https://github.com/apache/incubator-dubbo/issues/new?template=dubbo-issue-report-template.md)
* Gitter: [Gitter channel](https://gitter.im/alibaba/dubbo) 
* Twitter: [@ApacheDubbo](https://twitter.com/ApacheDubbo)

## Contributing

See [CONTRIBUTING](https://github.com/apache/incubator-dubbo/blob/master/CONTRIBUTING.md) for details on submitting patches and the contribution workflow.

201 202
### How can I contribute?

H
Huxing Zhang 已提交
203
* Take a look at issues with tag called [`Good first issue`](https://github.com/apache/incubator-dubbo/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22) or [`Help wanted`](https://github.com/apache/incubator-dubbo/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22).
204 205 206 207 208 209 210 211
* Join the discussion on mailing list, subscription [guide](https://github.com/apache/incubator-dubbo/wiki/Mailing-list-subscription-guide).
* Answer questions on [issues](https://github.com/apache/incubator-dubbo/issues).
* Fix bugs reported on [issues](https://github.com/apache/incubator-dubbo/issues), and send us pull request.
* Review the existing [pull request](https://github.com/apache/incubator-dubbo/pulls).
* Improve the [website](https://github.com/apache/incubator-dubbo-website), typically we need
  * blog post
  * translation on documentation
  * use cases about how Dubbo is being used in enterprise system.
212
* Improve the [dubbo-admin/dubbo-monitor](https://github.com/apache/incubator-dubbo-admin).
213 214 215 216
* Contribute to the projects listed in [ecosystem](https://github.com/dubbo).
* Any form of contribution that is not mentioned above.
* If you would like to contribute, please send an email to dev@dubbo.incubator.apache.org to let us know!

H
Huxing Zhang 已提交
217 218
## Reporting bugs

H
Huxing Zhang 已提交
219
Please follow the [template](https://github.com/apache/incubator-dubbo/issues/new?template=dubbo-issue-report-template.md) for reporting any issues.
H
Huxing Zhang 已提交
220 221 222

## Reporting a security vulnerability

H
Huxing Zhang 已提交
223
Please report security vulnerability to [us](mailto:security@dubbo.incubator.apache.org) privately.
H
Huxing Zhang 已提交
224

S
Song Kun 已提交
225
## Dubbo ecosystem
H
Huxing Zhang 已提交
226

I
Ian Luo 已提交
227
* [Dubbo Ecosystem Entry](https://github.com/dubbo) - A GitHub group `dubbo` to gather all Dubbo relevant projects not appropriate in [apache](https://github.com/apache) group yet
228
* [Dubbo Website](https://github.com/apache/incubator-dubbo-website) - Apache Dubbo (incubating) official website
S
Song Kun 已提交
229
* [Dubbo Samples](https://github.com/apache/incubator-dubbo-samples) - samples for Apache Dubbo (incubating)
H
Huxing Zhang 已提交
230
* [Dubbo Spring Boot](https://github.com/apache/incubator-dubbo-spring-boot-project) - Spring Boot Project for Dubbo
231
* [Dubbo Admin](https://github.com/apache/incubator-dubbo-admin) - The reference implementation for Dubbo admin
H
Huxing Zhang 已提交
232 233 234 235 236

#### Language

* [Node.js](https://github.com/dubbo/dubbo2.js)
* [Python](https://github.com/dubbo/dubbo-client-py)
S
Song Kun 已提交
237
* [PHP](https://github.com/dubbo/dubbo-php-framework)
H
Huxing Zhang 已提交
238
* [Go](https://github.com/dubbo/dubbo-go)
H
Huxing Zhang 已提交
239 240 241 242

## License

Apache Dubbo is under the Apache 2.0 license. See the [LICENSE](https://github.com/apache/incubator-dubbo/blob/master/LICENSE) file for details.