Create distributed services without writing extra code.
Provides cluster support and integrate with popular service discovery services like Consul
or 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 or Gradle
Synchronous calls
Add dependencies to pom.
<properties>
<motan.version>1.1.12</motan.version> <!--use the latest version from maven central-->
</properties>
<dependencies>
<dependency>
<groupId>com.weibo</groupId>
<artifactId>motan-core</artifactId>
<version>${motan.version}</version>
</dependency>
<dependency>
<groupId>com.weibo</groupId>
<artifactId>motan-transport-netty</artifactId>
<version>${motan.version}</version>
</dependency>
<!-- dependencies below were only needed for spring-based features -->
<dependency>
<groupId>com.weibo</groupId>
<artifactId>motan-springsupport</artifactId>
<version>${motan.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.2.4.RELEASE</version>
</dependency>
</dependencies>
Create an interface for both service provider and consumer.
src/main/java/quickstart/FooService.java
package quickstart;
public interface FooService {
public String hello(String name);
}
Write an implementation, create and start RPC Server.
src/main/java/quickstart/FooServiceImpl.java
package quickstart;
public class FooServiceImpl implements FooService {
public String hello(String name) {
System.out.println(name + " invoked rpc service");
return "hello " + name;
}
}
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:
Features
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.
Synchronous calls
Create an interface for both service provider and consumer.
src/main/java/quickstart/FooService.javaWrite an implementation, create and start RPC Server.
src/main/java/quickstart/FooServiceImpl.javasrc/main/resources/motan_server.xmlsrc/main/java/quickstart/Server.javaExecute main function in Server will start a motan server listening on port 8002.
Create and start RPC Client.
src/main/resources/motan_client.xmlsrc/main/java/quickstart/Client.java```java package quickstart;
import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext;
Execute main function in Client will invoke the remote service and print response.
Asynchronous calls
Based on the
Synchronous callsexample, add@MotanAsyncannotation to interfaceFooService.Include the plugin into the POM file to set
target/generated-sources/annotations/as source folder.Modify the attribute
interfaceof referer inmotan_client.xmlfromFooServicetoFooServiceAsync.Start asynchronous calls.
Documents
Contributors
License
Motan is released under the Apache License 2.0.