{"id":16298805,"url":"https://github.com/linshenkx/rpc-netty-spring-boot-starter","last_synced_at":"2025-09-06T22:38:23.546Z","repository":{"id":165126749,"uuid":"155843690","full_name":"linshenkx/rpc-netty-spring-boot-starter","owner":"linshenkx","description":"基于Netty的小型RPC框架","archived":false,"fork":false,"pushed_at":"2018-12-02T02:08:39.000Z","size":142,"stargazers_count":15,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-03T10:51:23.549Z","etag":null,"topics":["netty","netty-rpc","rpc","spring-boot"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/linshenkx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2018-11-02T09:28:55.000Z","updated_at":"2023-03-30T05:11:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"39325263-8cec-420b-b14e-979ea4d9d22b","html_url":"https://github.com/linshenkx/rpc-netty-spring-boot-starter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/linshenkx/rpc-netty-spring-boot-starter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linshenkx%2Frpc-netty-spring-boot-starter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linshenkx%2Frpc-netty-spring-boot-starter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linshenkx%2Frpc-netty-spring-boot-starter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linshenkx%2Frpc-netty-spring-boot-starter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/linshenkx","download_url":"https://codeload.github.com/linshenkx/rpc-netty-spring-boot-starter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linshenkx%2Frpc-netty-spring-boot-starter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273973970,"owners_count":25200578,"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","status":"online","status_checked_at":"2025-09-06T02:00:13.247Z","response_time":2576,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["netty","netty-rpc","rpc","spring-boot"],"created_at":"2024-10-10T20:45:26.892Z","updated_at":"2025-09-06T22:38:23.519Z","avatar_url":"https://github.com/linshenkx.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 基于Netty的简易RPC框架\n一个基于Netty,Zookeeper和SpringBoot的RPC框架\n\n作者CSDN主页：[鲸临于空](https://blog.csdn.net/alinyua)\n\n### 特性:\n* 基于Spring Boot 2的自动发现,添加Starter依赖即可快速集成，开箱即用\n* 基于ZooKeeper的服务发现，支持ZooKeeper集群\n* 基于Netty的底层通信\n\n### 版本：2.0\n\n### 版本说明：\n1.0版本实现了原型功能，达到初步可用状态，但性能较差，仅作学习交流用\n\n2.0版本针对性能做了优化，并添加一些新功能：\n\n* 增加@RpcReference注解，自动注入服务实现\n* 增加负载均衡路由策略引擎（含随机、轮询、哈希等及其带权形式）\n* 增加序列化引擎（支持 JDK默认、Hessian、Json、Protostuff、Xml、Avro、ProtocolBuffer、Thrift等序列化方式）\n* 服务提供者提供服务时可注解参数指定最大工作线程数来限流\n* 服务消费者对服务地址列表进行缓存，并监听变化\n* 传输协议修改，使用消息头+消息体的模式以支持新特性并避免粘包半包问题和留下扩展空间\n\n后续将对核心进行改造，使其支持异步模型\n\n### 设计:\n![design](https://img-blog.csdnimg.cn/20181106001830876.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2FsaW55dWE=,size_16,color_FFFFFF,t_70)\n### 快速启动\n\n以下例子可参考：[examples](https://github.com/linshenkx/rpc-netty-spring-boot-starter/tree/master/examples)\n\n1. 定义公共接口:\n\n\t\tpublic interface HelloService { \n\t\t\tString hello(String name); \n\t\t}\n\n2. 添加对应依赖(注意更新到最新版本)\n    - 服务提供者：\n    ```xml\n            \u003cdependency\u003e\n                \u003cgroupId\u003ecom.github.linshenkx\u003c/groupId\u003e\n                \u003cartifactId\u003erpc-netty-server-spring-boot-starter\u003c/artifactId\u003e\n                \u003cversion\u003e2.0.2.RELEASE\u003c/version\u003e\n            \u003c/dependency\u003e\n    ```\n\n    - 服务消费者：\n    ```xml\n        \u003cdependency\u003e\n            \u003cgroupId\u003ecom.github.linshenkx\u003c/groupId\u003e\n            \u003cartifactId\u003erpc-netty-client-spring-boot-starter\u003c/artifactId\u003e\n            \u003cversion\u003e2.0.2.RELEASE\u003c/version\u003e\n        \u003c/dependency\u003e\n    ``` \n    \n3. 在Spring配置文件里配置zookeeper地址列表和rpc端口,如下例，\n\n    其中connectTimeOut和sessionTimeOut都有默认值，应根据网络环境配置修改\n    \n    服务提供者和服务消费者应使用相同 registryPath，一般无需配置，使用默认值即可（如果有多个不同系统则可修改，达到隔离目的）\n    \n    1. 服务提供者 application 文件\n    \n        ```yml\n            zk:\n              address: 127.0.0.1:2181,127.0.0.1:2182,127.0.0.1:2183\n              connectTimeOut: 10000\n              sessionTimeOut: 10000\n              registryPath: \"/defaultRegistry\"\n            rpc:\n              server:\n                port: 9991\n            ```\n    2. 服务消费者 application 文件\n    \n        ```yml\n            server:\n              port: 9090\n            zk:\n              address: 127.0.0.1:2181,127.0.0.1:2182,127.0.0.1:2183\n              connectTimeOut: 20000\n              sessionTimeOut: 10000\n              registryPath: \"/defaultRegistry\"\n            rpc:\n              client:\n                routeStrategy: Polling\n                serializeType: ProtoStuff\n            ```\n4. 服务提供方使用@RpcService标注接口实现 :\n   其中weight代表权重，默认为1。workerThreads代表工作线程数，可用于限流，默认为10.\n    ```java\n    @RpcService(value = HelloService.class,weight = 2,workerThreads = 3)\n    public class HelloServiceImpl implements HelloService {\n    \n      @Override\n      public String say(String name) {\n        return \"hello \" + name;\n      }\n    \n    }\n    ```\n\n5. 服务消费者使用@RpcReference标记服务接口，即可注入服务实现类代理\n    \n    ```java\n    @RestController\n    public class HelloController {\n    \n        @RpcReference\n        private HelloService helloService;\n    \n        @GetMapping(\"/hello\")\n        public String sayHello(@RequestParam(defaultValue = \"lin\") String name){   \n            return helloService.say(name);\n        }\n    \n    }\n    ```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinshenkx%2Frpc-netty-spring-boot-starter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flinshenkx%2Frpc-netty-spring-boot-starter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinshenkx%2Frpc-netty-spring-boot-starter/lists"}