{"id":13470215,"url":"https://github.com/weibocom/motan","last_synced_at":"2025-05-12T13:26:54.605Z","repository":{"id":37175408,"uuid":"56679521","full_name":"weibocom/motan","owner":"weibocom","description":"A cross-language remote procedure call(RPC) framework for rapid development of high performance distributed services.","archived":false,"fork":false,"pushed_at":"2025-05-07T06:15:21.000Z","size":4596,"stargazers_count":5888,"open_issues_count":363,"forks_count":1768,"subscribers_count":607,"default_branch":"master","last_synced_at":"2025-05-07T07:28:22.948Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/weibocom.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-04-20T10:56:17.000Z","updated_at":"2025-04-29T08:52:32.000Z","dependencies_parsed_at":"2023-01-30T17:31:14.797Z","dependency_job_id":"fe1b40a4-9be1-44ff-8d9d-853af5349c70","html_url":"https://github.com/weibocom/motan","commit_stats":{"total_commits":491,"total_committers":50,"mean_commits":9.82,"dds":0.5865580448065173,"last_synced_commit":"6aef3476fd340313eb94adf15fcd49a112e9ec7a"},"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weibocom%2Fmotan","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weibocom%2Fmotan/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weibocom%2Fmotan/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weibocom%2Fmotan/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/weibocom","download_url":"https://codeload.github.com/weibocom/motan/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253746929,"owners_count":21957657,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T16:00:25.694Z","updated_at":"2025-05-12T13:26:54.586Z","avatar_url":"https://github.com/weibocom.png","language":"Java","funding_links":[],"categories":["Java","开发框架","中间件","数据库和中间件","RPC框架"],"sub_categories":["RPC"],"readme":"# Motan\n\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/weibocom/motan/blob/master/LICENSE)\n[![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)\n[![codecov](https://codecov.io/gh/weibocom/motan/branch/master/graph/badge.svg?token=ngBqL0SPJS)](https://codecov.io/gh/weibocom/motan)\n[![OpenTracing-1.0 Badge](https://img.shields.io/badge/OpenTracing--1.0-enabled-blue.svg)](http://opentracing.io)\n[![Skywalking Tracing](https://img.shields.io/badge/Skywalking%20Tracing-enable-brightgreen.svg)](https://github.com/OpenSkywalking/skywalking)\n\n# Overview\n\nMotan is a cross-language remote procedure call(RPC) framework for rapid development of high performance distributed\nservices.\n\nRelated projects in Motan ecosystem:\n\n- [Motan-go](https://github.com/weibocom/motan-go) is golang implementation.\n- [Motan-PHP](https://github.com/weibocom/motan-php) is PHP client can interactive with Motan server directly or through\n  Motan-go agent.\n- [Motan-openresty](https://github.com/weibocom/motan-openresty) is a Lua(Luajit) implementation based\n  on [Openresty](http://openresty.org).\n\n# Features\n\n- Create distributed services without writing extra code.\n- Provides cluster support and integrate with popular service discovery services like [Consul][consul]\n  or [Zookeeper][zookeeper].\n- Supports advanced scheduling features like weighted load-balance, scheduling cross IDCs, etc.\n- Optimization for high load scenarios, provides high availability in production environment.\n- Supports both synchronous and asynchronous calls.\n- Support cross-language interactive with Golang, PHP, Lua(Luajit), etc.\n\n# Quick Start\n\nThe quick start gives very basic example of running client and server on the same machine. For the detailed information\nabout using and developing Motan, please jump to [Documents](#documents).\n\n\u003e The minimum requirements to run the quick start are:\n\u003e\n\u003e - JDK 1.8 or above\n\u003e - A java-based project management software like [Maven][maven] or [Gradle][gradle]\n\n## Synchronous calls\n\n1. Add dependencies to pom.\n\n```xml\n\n\u003cproperties\u003e\n    \u003cmotan.version\u003e1.1.12\u003c/motan.version\u003e \u003c!--use the latest version from maven central--\u003e\n\u003c/properties\u003e\n\u003cdependencies\u003e\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.weibo\u003c/groupId\u003e\n    \u003cartifactId\u003emotan-core\u003c/artifactId\u003e\n    \u003cversion\u003e${motan.version}\u003c/version\u003e\n\u003c/dependency\u003e\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.weibo\u003c/groupId\u003e\n    \u003cartifactId\u003emotan-transport-netty\u003c/artifactId\u003e\n    \u003cversion\u003e${motan.version}\u003c/version\u003e\n\u003c/dependency\u003e\n\n\u003c!-- dependencies below were only needed for spring-based features --\u003e\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.weibo\u003c/groupId\u003e\n    \u003cartifactId\u003emotan-springsupport\u003c/artifactId\u003e\n    \u003cversion\u003e${motan.version}\u003c/version\u003e\n\u003c/dependency\u003e\n\u003cdependency\u003e\n    \u003cgroupId\u003eorg.springframework\u003c/groupId\u003e\n    \u003cartifactId\u003espring-context\u003c/artifactId\u003e\n    \u003cversion\u003e4.2.4.RELEASE\u003c/version\u003e\n\u003c/dependency\u003e\n\u003c/dependencies\u003e\n```\n\n2. Create an interface for both service provider and consumer.\n\n   `src/main/java/quickstart/FooService.java`\n\n    ```java\n    package quickstart;\n\n    public interface FooService {\n        public String hello(String name);\n    }\n    ```\n\n3. Write an implementation, create and start RPC Server.\n\n   `src/main/java/quickstart/FooServiceImpl.java`\n\n    ```java\n    package quickstart;\n\n    public class FooServiceImpl implements FooService {\n\n        public String hello(String name) {\n            System.out.println(name + \" invoked rpc service\");\n            return \"hello \" + name;\n        }\n    }\n    ```\n\n   `src/main/resources/motan_server.xml`\n\n    ```xml\n    \u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n    \u003cbeans xmlns=\"http://www.springframework.org/schema/beans\"\n        xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n        xmlns:motan=\"http://api.weibo.com/schema/motan\"\n        xsi:schemaLocation=\"http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\n       http://api.weibo.com/schema/motan http://api.weibo.com/schema/motan.xsd\"\u003e\n\n        \u003c!-- service implementation bean --\u003e\n        \u003cbean id=\"serviceImpl\" class=\"quickstart.FooServiceImpl\" /\u003e\n        \u003c!-- exporting service by motan --\u003e\n        \u003cmotan:service interface=\"quickstart.FooService\" ref=\"serviceImpl\" export=\"8002\" /\u003e\n    \u003c/beans\u003e\n    ```\n\n   `src/main/java/quickstart/Server.java`\n\n    ```java\n    package quickstart;\n\n    import org.springframework.context.ApplicationContext;\n    import org.springframework.context.support.ClassPathXmlApplicationContext;\n\n    public class Server {\n\n        public static void main(String[] args) throws InterruptedException {\n            ApplicationContext applicationContext = new ClassPathXmlApplicationContext(\"classpath:motan_server.xml\");\n            System.out.println(\"server start...\");\n        }\n    }\n    ```\n\n   Execute main function in Server will start a motan server listening on port 8002.\n\n4. Create and start RPC Client.\n\n   `src/main/resources/motan_client.xml`\n\n    ```xml\n    \u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n    \u003cbeans xmlns=\"http://www.springframework.org/schema/beans\"\n    xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n    xmlns:motan=\"http://api.weibo.com/schema/motan\"\n    xsi:schemaLocation=\"http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\n       http://api.weibo.com/schema/motan http://api.weibo.com/schema/motan.xsd\"\u003e\n\n        \u003c!-- reference to the remote service --\u003e\n        \u003cmotan:referer id=\"remoteService\" interface=\"quickstart.FooService\" directUrl=\"localhost:8002\"/\u003e\n    \u003c/beans\u003e\n    ```\n\n   `src/main/java/quickstart/Client.java`\n\n    ```java\n    package quickstart;\n\n    import org.springframework.context.ApplicationContext;\n    import org.springframework.context.support.ClassPathXmlApplicationContext;\n\n\n    public class Client {\n\n        public static void main(String[] args) throws InterruptedException {\n            ApplicationContext ctx = new ClassPathXmlApplicationContext(\"classpath:motan_client.xml\");\n            FooService service = (FooService) ctx.getBean(\"remoteService\");\n            System.out.println(service.hello(\"motan\"));\n        }\n    }\n    ```\n\n   Execute main function in Client will invoke the remote service and print response.\n\n## Asynchronous calls\n\n1. Based on the `Synchronous calls` example, add `@MotanAsync` annotation to interface `FooService`.\n\n    ```java\n    package quickstart;\n    import com.weibo.api.motan.transport.async.MotanAsync;\n\n    @MotanAsync\n    public interface FooService {\n        public String hello(String name);\n    }\n    ```\n\n2. Include the plugin into the POM file to set `target/generated-sources/annotations/` as source folder.\n\n    ```xml\n    \u003cplugin\u003e\n        \u003cgroupId\u003eorg.codehaus.mojo\u003c/groupId\u003e\n        \u003cartifactId\u003ebuild-helper-maven-plugin\u003c/artifactId\u003e\n        \u003cversion\u003e1.10\u003c/version\u003e\n        \u003cexecutions\u003e\n            \u003cexecution\u003e\n                \u003cphase\u003egenerate-sources\u003c/phase\u003e\n                \u003cgoals\u003e\n                    \u003cgoal\u003eadd-source\u003c/goal\u003e\n                \u003c/goals\u003e\n                \u003cconfiguration\u003e\n                    \u003csources\u003e\n                        \u003csource\u003e${project.build.directory}/generated-sources/annotations\u003c/source\u003e\n                    \u003c/sources\u003e\n                \u003c/configuration\u003e\n            \u003c/execution\u003e\n        \u003c/executions\u003e\n    \u003c/plugin\u003e\n    ```\n\n3. Modify the attribute `interface` of referer in `motan_client.xml` from `FooService` to `FooServiceAsync`.\n\n    ```xml\n    \u003cmotan:referer id=\"remoteService\" interface=\"quickstart.FooServiceAsync\" directUrl=\"localhost:8002\"/\u003e\n    ```\n\n4. Start asynchronous calls.\n\n    ```java\n    public static void main(String[] args) {\n        ApplicationContext ctx = new ClassPathXmlApplicationContext(new String[] {\"classpath:motan_client.xml\"});\n\n        FooServiceAsync service = (FooServiceAsync) ctx.getBean(\"remoteService\");\n\n        // sync call\n        System.out.println(service.hello(\"motan\"));\n\n        // async call\n        ResponseFuture future = service.helloAsync(\"motan async \");\n        System.out.println(future.getValue());\n\n        // multi call\n        ResponseFuture future1 = service.helloAsync(\"motan async multi-1\");\n        ResponseFuture future2 = service.helloAsync(\"motan async multi-2\");\n        System.out.println(future1.getValue() + \", \" + future2.getValue());\n\n        // async with listener\n        FutureListener listener = new FutureListener() {\n            @Override\n            public void operationComplete(Future future) throws Exception {\n                System.out.println(\"async call \"\n                        + (future.isSuccess() ? \"success! value:\" + future.getValue() : \"fail! exception:\"\n                                + future.getException().getMessage()));\n            }\n        };\n        ResponseFuture future3 = service.helloAsync(\"motan async multi-1\");\n        ResponseFuture future4 = service.helloAsync(\"motan async multi-2\");\n        future3.addListener(listener);\n        future4.addListener(listener);\n    }\n    ```\n\n# Documents\n\n- [Wiki](https://github.com/weibocom/motan/wiki)\n- [Wiki(中文)](https://github.com/weibocom/motan/wiki/zh_overview)\n\n# Contributors\n\n- maijunsheng([@maijunsheng](https://github.com/maijunsheng))\n- fishermen([@hustfisher](https://github.com/hustfisher))\n- TangFulin([@tangfl](https://github.com/tangfl))\n- bodlyzheng([@bodlyzheng](https://github.com/bodlyzheng))\n- jacawang([@jacawang](https://github.com/jacawang))\n- zenglingshu([@zenglingshu](https://github.com/zenglingshu))\n- Sugar Zouliu([@lamusicoscos](https://github.com/lamusicoscos))\n- tangyang([@tangyang](https://github.com/tangyang))\n- olivererwang([@olivererwang](https://github.com/olivererwang))\n- jackael([@jackael9856](https://github.com/jackael9856))\n- Ray([@rayzhang0603](https://github.com/rayzhang0603))\n- r2dx([@half-dead](https://github.com/half-dead))\n- Jake Zhang([sunnights](https://github.com/sunnights))\n- axb([@qdaxb](https://github.com/qdaxb))\n- wenqisun([@wenqisun](https://github.com/wenqisun))\n- fingki([@fingki](https://github.com/fingki))\n- 午夜([@sumory](https://github.com/sumory))\n- guanly([@guanly](https://github.com/guanly))\n- Di Tang([@tangdi](https://github.com/tangdi))\n- 肥佬大([@feilaoda](https://github.com/feilaoda))\n- 小马哥([@andot](https://github.com/andot))\n- wu-sheng([@wu-sheng](https://github.com/wu-sheng)) \u0026nbsp;\u0026nbsp;\u0026nbsp; _Assist Motan to become the first Chinese RPC\n  framework on [OpenTracing](http://opentracing.io) **Supported Frameworks List**_\n- Jin Zhang([@lowzj](https://github.com/lowzj))\n- xiaoqing.yuanfang([@xiaoqing-yuanfang](https://github.com/xiaoqing-yuanfang))\n- 东方上人([@dongfangshangren](https://github.com/dongfangshangren))\n- Voyager3([@xxxxzr](https://github.com/xxxxzr))\n- yeluoguigen009([@yeluoguigen009](https://github.com/yeluoguigen009))\n- Michael Yang([@yangfuhai](https://github.com/yangfuhai))\n- Panying([@anylain](https://github.com/anylain))\n\n# License\n\nMotan is released under the [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0).\n\n[maven]:https://maven.apache.org\n\n[gradle]:http://gradle.org\n\n[consul]:http://www.consul.io\n\n[zookeeper]:http://zookeeper.apache.org\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweibocom%2Fmotan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweibocom%2Fmotan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweibocom%2Fmotan/lists"}