weibocom /motan

A cross-language remote procedure call(RPC) framework for rapid development of high performance distributed services.

★ 5,857⑂ 1,730👁 590⑃ 291● 795▤ 28
JavaNOASSERTIONCreated 2016-04-20
Download: release 1.2.6release-1.2.6 ↓1.2.62025-09-15
+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

Latest release

release 1.2.6 1.2.6 2025-09-15
release 1.2.6

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON