+0
Daily
5,857
stars
1,730
forks
590
watchers
291
prs
795
issues
28
releases
README
Motan
Overview
Motan is a cross-language remote procedure call(RPC) framework for rapid development of high performance distributed
services.
Related projects in Motan ecosystem:
- Motan-go is golang implementation.
- Motan-PHP is PHP client can interactive with Motan server directly or through
Motan-go agent.
- Motan-openresty is a Lua(Luajit) implementation based
on Openresty.
Features
- Create distributed services without writing extra code.
- 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.
- Support cross-language interactive with Golang, PHP, Lua(Luajit), etc.
Quick Start
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.
The minimum requirements to run the quick start are:
- JDK 1.8 or above
- A java-based project management software like [Maven][maven] or [Gradle][gradle]
Synchronous calls
1. Add dependencies to pom.
xml
1.1.12
com.weibo
motan-core
${motan.version}
com.weibo
motan-transport-netty
${motan.version}
com.weibo
motan-springsupport
${motan.version}
org.springframework
spring-context
4.2.4.RELEASE
2. Create an interface for both service provider and consumer.
src/main/java/quickstart/FooService.java
java
package quickstart;
public interface FooService {
public String hello(String name);
}
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) {
System.out.println(name + " invoked rpc service");
return "hello " + name;
}
}
src/main/resources/motan_server.xml
xml
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.
src/main/resources/motan_client.xml
xml
Top issues
#360Connection reset by peer18 comments · 2017-02-16#437motan-memoryStatistic这个内存为什么一直涨?14 comments · 2017-05-17#598Yar协议中文序列化问题13 comments · 2017-11-30#569motan-jar冲突问题:spring4.2.4+motan0.3.0启动报错,版本依赖有什么要求吗13 comments · 2017-11-07#420web项目调用rpc接口后,在停止tomcat的时候,停不下来,必须kill才行,怎么破?12 comments · 2017-04-25#348有没有像dubbo那样做泛化调用12 comments · 2017-02-04#689jar包无法下载11 comments · 2018-04-19#352为什么注册服务和关闭节点是同一句代码?11 comments · 2017-02-07
Latest release
release 1.2.6 1.2.6 2025-09-15release 1.2.6