Skip to content

Commit

Permalink
Merge pull request #890 from oldratlee/master
Browse files Browse the repository at this point in the history
improve README: fix typo and improve format
  • Loading branch information
rayzhang0603 authored Mar 6, 2020
2 parents e56b33a + 50e1fab commit f36fce9
Showing 1 changed file with 87 additions and 85 deletions.
172 changes: 87 additions & 85 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
# Motan

[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/weibocom/motan/blob/master/LICENSE)
[![Maven Central](https://img.shields.io/maven-central/v/com.weibo/motan.svg?label=Maven%20Central)](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.weibo%22%20AND%20motan)
[![Build Status](https://img.shields.io/travis/weibocom/motan/master.svg?label=Build)](https://travis-ci.org/weibocom/motan)
[![OpenTracing-1.0 Badge](https://img.shields.io/badge/OpenTracing--1.0-enabled-blue.svg)](http://opentracing.io)
[![Skywalking Tracing](https://img.shields.io/badge/Skywalking%20Tracing-enable-brightgreen.svg)](https://github.com/OpenSkywalking/skywalking)

# Overview
Motan is a cross-language remote procedure call(RPC) framework for rapid development of high performance distributed services.

[Motan-go](https://github.com/weibocom/motan-go) is golang implementation.
Motan is a cross-language remote procedure call(RPC) framework for rapid development of high performance distributed services.

[Motan-PHP](https://github.com/weibocom/motan-php) is PHP client can interactive with Motan server directly or through Motan-go agent.
Related projects in Motan ecosystem:

[Motan-openresty](https://github.com/weibocom/motan-openresty) is a Lua(Luajit) implementation based on [Openresty](http://openresty.org)
- [Motan-go](https://github.com/weibocom/motan-go) is golang implementation.
- [Motan-PHP](https://github.com/weibocom/motan-php) is PHP client can interactive with Motan server directly or through Motan-go agent.
- [Motan-openresty](https://github.com/weibocom/motan-openresty) is a Lua(Luajit) implementation based on [Openresty](http://openresty.org).

# Features

- Create distributed services without writing extra code.
- Provides cluster support and integrate with popular service discovery services like [Consul][consul] or [Zookeeper][zookeeper].
- Provides cluster support and integrate with popular service discovery services like [Consul][consul] or [Zookeeper][zookeeper].
- Supports advanced scheduling features like weighted load-balance, scheduling cross IDCs, etc.
- Optimization for high load scenarios, provides high availability in production environment.
- Supports both synchronous and asynchronous calls.
Expand All @@ -26,37 +29,38 @@ Motan is a cross-language remote procedure call(RPC) framework for rapid develop

The quick start gives very basic example of running client and server on the same machine. For the detailed information about using and developing Motan, please jump to [Documents](#documents).

> The minimum requirements to run the quick start are:
> * JDK 1.7 or above
> * A java-based project management software like [Maven][maven] or [Gradle][gradle]
> The minimum requirements to run the quick start are:
>
> - JDK 1.7 or above
> - A java-based project management software like [Maven][maven] or [Gradle][gradle]
## Synchronous calls

1. Add dependencies to pom.

```xml
<dependency>
<groupId>com.weibo</groupId>
<artifactId>motan-core</artifactId>
       <version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.weibo</groupId>
<artifactId>motan-transport-netty</artifactId>
<version>1.0.0</version>
</dependency>
<!-- dependencies blow were only needed for spring-based features -->
<dependency>
<groupId>com.weibo</groupId>
<artifactId>motan-springsupport</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.2.4.RELEASE</version>
</dependency>
<dependency>
<groupId>com.weibo</groupId>
<artifactId>motan-core</artifactId>
       <version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.weibo</groupId>
<artifactId>motan-transport-netty</artifactId>
<version>1.0.0</version>
</dependency>

<!-- dependencies blow were only needed for spring-based features -->
<dependency>
<groupId>com.weibo</groupId>
<artifactId>motan-springsupport</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.2.4.RELEASE</version>
</dependency>
```

2. Create an interface for both service provider and consumer.
Expand All @@ -72,55 +76,55 @@ The quick start gives very basic example of running client and server on the sam
```

3. Write an implementation, create and start RPC Server.

`src/main/java/quickstart/FooServiceImpl.java`

```java
package quickstart;

public class FooServiceImpl implements FooService {

public String hello(String name) {
public String hello(String name) {
System.out.println(name + " invoked rpc service");
return "hello " + name;
}
}
}
```

`src/main/resources/motan_server.xml`

```xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:motan="http://api.weibo.com/schema/motan"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:motan="http://api.weibo.com/schema/motan"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://api.weibo.com/schema/motan http://api.weibo.com/schema/motan.xsd">

<!-- service implemention bean -->
<!-- service implementation bean -->
<bean id="serviceImpl" class="quickstart.FooServiceImpl" />
<!-- exporting service by motan -->
<motan:service interface="quickstart.FooService" ref="serviceImpl" export="8002" />
</beans>
```

`src/main/java/quickstart/Server.java`

```java
package quickstart;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Server {

public static void main(String[] args) throws InterruptedException {
ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:motan_server.xml");
System.out.println("server start...");
}
}
```

Execute main function in Server will start a motan server listening on port 8002.

4. Create and start RPC Client.
Expand Down Expand Up @@ -150,25 +154,25 @@ The quick start gives very basic example of running client and server on the sam


public class Client {

public static void main(String[] args) throws InterruptedException {
ApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:motan_client.xml");
FooService service = (FooService) ctx.getBean("remoteService");
System.out.println(service.hello("motan"));
}
}
```

Execute main function in Client will invoke the remote service and print response.

## Asynchronous calls
## Asynchronous calls

1. Based on the `Synchronous calls` example, add `@MotanAsync` annotation to interface `FooService`.

```java
package quickstart;
import com.weibo.api.motan.transport.async.MotanAsync;

@MotanAsync
public interface FooService {
public String hello(String name);
Expand Down Expand Up @@ -198,12 +202,12 @@ The quick start gives very basic example of running client and server on the sam
</plugin>
```

3. Modify referer's attribute `interface` in `motan_client.xml` from `FooService` to `FooServiceAsync`.
3. Modify the attribute `interface` of referer in `motan_client.xml` from `FooService` to `FooServiceAsync`.

```xml
<motan:referer id="remoteService" interface="quickstart.FooServiceAsync" directUrl="localhost:8002"/>
```

4. Start asynchronous calls.

```java
Expand All @@ -229,7 +233,7 @@ The quick start gives very basic example of running client and server on the sam
@Override
public void operationComplete(Future future) throws Exception {
System.out.println("async call "
+ (future.isSuccess() ? "sucess! value:" + future.getValue() : "fail! exception:"
+ (future.isSuccess() ? "success! value:" + future.getValue() : "fail! exception:"
+ future.getException().getMessage()));
}
};
Expand All @@ -243,40 +247,40 @@ The quick start gives very basic example of running client and server on the sam

# Documents

* [Wiki](https://github.com/weibocom/motan/wiki)
* [Wiki(中文)](https://github.com/weibocom/motan/wiki/zh_overview)
- [Wiki](https://github.com/weibocom/motan/wiki)
- [Wiki(中文)](https://github.com/weibocom/motan/wiki/zh_overview)

# Contributors

* maijunsheng([@maijunsheng](https://github.com/maijunsheng))
* fishermen([@hustfisher](https://github.com/hustfisher))
* TangFulin([@tangfl](https://github.com/tangfl))
* bodlyzheng([@bodlyzheng](https://github.com/bodlyzheng))
* jacawang([@jacawang](https://github.com/jacawang))
* zenglingshu([@zenglingshu](https://github.com/zenglingshu))
* Sugar Zouliu([@lamusicoscos](https://github.com/lamusicoscos))
* tangyang([@tangyang](https://github.com/tangyang))
* olivererwang([@olivererwang](https://github.com/olivererwang))
* jackael([@jackael9856](https://github.com/jackael9856))
* Ray([@rayzhang0603](https://github.com/rayzhang0603))
* r2dx([@half-dead](https://github.com/half-dead))
* Jake Zhang([sunnights](https://github.com/sunnights))
* axb([@qdaxb](https://github.com/qdaxb))
* wenqisun([@wenqisun](https://github.com/wenqisun))
* fingki([@fingki](https://github.com/fingki))
* 午夜([@sumory](https://github.com/sumory))
* guanly([@guanly](https://github.com/guanly))
* Di Tang([@tangdi](https://github.com/tangdi))
* 肥佬大([@feilaoda](https://github.com/feilaoda))
* 小马哥([@andot](https://github.com/andot))
* wu-sheng([@wu-sheng](https://github.com/wu-sheng)) &nbsp;&nbsp;&nbsp; _Assist Motan to become the first Chinese RPC framework on [OpenTracing](http://opentracing.io) **Supported Frameworks List**_
* Jin Zhang([@lowzj](https://github.com/lowzj))
* xiaoqing.yuanfang([@xiaoqing-yuanfang](https://github.com/xiaoqing-yuanfang))
* 东方上人([@dongfangshangren](https://github.com/dongfangshangren))
* Voyager3([@xxxxzr](https://github.com/xxxxzr))
* yeluoguigen009([@yeluoguigen009](https://github.com/yeluoguigen009))
* Michael Yang([@yangfuhai](https://github.com/yangfuhai))
* Panying([@anylain](https://github.com/anylain))
- maijunsheng([@maijunsheng](https://github.com/maijunsheng))
- fishermen([@hustfisher](https://github.com/hustfisher))
- TangFulin([@tangfl](https://github.com/tangfl))
- bodlyzheng([@bodlyzheng](https://github.com/bodlyzheng))
- jacawang([@jacawang](https://github.com/jacawang))
- zenglingshu([@zenglingshu](https://github.com/zenglingshu))
- Sugar Zouliu([@lamusicoscos](https://github.com/lamusicoscos))
- tangyang([@tangyang](https://github.com/tangyang))
- olivererwang([@olivererwang](https://github.com/olivererwang))
- jackael([@jackael9856](https://github.com/jackael9856))
- Ray([@rayzhang0603](https://github.com/rayzhang0603))
- r2dx([@half-dead](https://github.com/half-dead))
- Jake Zhang([sunnights](https://github.com/sunnights))
- axb([@qdaxb](https://github.com/qdaxb))
- wenqisun([@wenqisun](https://github.com/wenqisun))
- fingki([@fingki](https://github.com/fingki))
- 午夜([@sumory](https://github.com/sumory))
- guanly([@guanly](https://github.com/guanly))
- Di Tang([@tangdi](https://github.com/tangdi))
- 肥佬大([@feilaoda](https://github.com/feilaoda))
- 小马哥([@andot](https://github.com/andot))
- wu-sheng([@wu-sheng](https://github.com/wu-sheng)) &nbsp;&nbsp;&nbsp; _Assist Motan to become the first Chinese RPC framework on [OpenTracing](http://opentracing.io) **Supported Frameworks List**_
- Jin Zhang([@lowzj](https://github.com/lowzj))
- xiaoqing.yuanfang([@xiaoqing-yuanfang](https://github.com/xiaoqing-yuanfang))
- 东方上人([@dongfangshangren](https://github.com/dongfangshangren))
- Voyager3([@xxxxzr](https://github.com/xxxxzr))
- yeluoguigen009([@yeluoguigen009](https://github.com/yeluoguigen009))
- Michael Yang([@yangfuhai](https://github.com/yangfuhai))
- Panying([@anylain](https://github.com/anylain))

# License

Expand All @@ -286,5 +290,3 @@ Motan is released under the [Apache License 2.0](http://www.apache.org/licenses/
[gradle]:http://gradle.org
[consul]:http://www.consul.io
[zookeeper]:http://zookeeper.apache.org

0 comments on commit f36fce9

Please sign in to comment.