{"id":28789179,"url":"https://github.com/naivetoby/simple-rpc","last_synced_at":"2026-01-16T10:05:01.450Z","repository":{"id":51770689,"uuid":"210425667","full_name":"naivetoby/simple-rpc","owner":"naivetoby","description":"一款非常轻量级的 RPC 调用框架，基于 RabbitMQ 消息队列，使用 Spring-Boot 开发","archived":false,"fork":false,"pushed_at":"2026-01-14T07:44:07.000Z","size":312,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-14T11:25:30.698Z","etag":null,"topics":["java","rabbitmq","rpc","spring-boot"],"latest_commit_sha":null,"homepage":"https://blog.toby.vip/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/naivetoby.png","metadata":{"files":{"readme":"README.md","changelog":null,"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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2019-09-23T18:32:44.000Z","updated_at":"2026-01-14T07:36:49.000Z","dependencies_parsed_at":"2023-12-30T15:25:05.630Z","dependency_job_id":"4bbca135-910b-4a9b-8c6a-71d60ef28fbd","html_url":"https://github.com/naivetoby/simple-rpc","commit_stats":null,"previous_names":["thinktkj/simple-rpc"],"tags_count":54,"template":false,"template_full_name":null,"purl":"pkg:github/naivetoby/simple-rpc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naivetoby%2Fsimple-rpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naivetoby%2Fsimple-rpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naivetoby%2Fsimple-rpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naivetoby%2Fsimple-rpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/naivetoby","download_url":"https://codeload.github.com/naivetoby/simple-rpc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naivetoby%2Fsimple-rpc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28478049,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T06:30:42.265Z","status":"ssl_error","status_checked_at":"2026-01-16T06:30:16.248Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["java","rabbitmq","rpc","spring-boot"],"created_at":"2025-06-17T22:01:20.842Z","updated_at":"2026-01-16T10:05:01.437Z","avatar_url":"https://github.com/naivetoby.png","language":"Java","readme":"## Simple-RPC\n\n 非常轻量级的 RPC 调用框架，基于 RabbitMQ 消息队列，使用 Spring-Boot 开发。\n\n## Spring-Boot \u0026\u0026 Simple-RPC Dependency\n\n```xml\n\u003cproject xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n         xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\"\u003e\n    \u003cmodelVersion\u003e4.0.0\u003c/modelVersion\u003e\n\n    \u003cparent\u003e\n        \u003cgroupId\u003eorg.springframework.boot\u003c/groupId\u003e\n        \u003cartifactId\u003espring-boot-starter-parent\u003c/artifactId\u003e\n        \u003cversion\u003e4.0.1\u003c/version\u003e\n    \u003c/parent\u003e\n    \n    \u003cgroupId\u003ecom.demo\u003c/groupId\u003e\n    \u003cartifactId\u003edemo\u003c/artifactId\u003e\n    \u003cversion\u003e3.3.2\u003c/version\u003e\n\n    \u003cdependencies\u003e\n        \u003cdependency\u003e\n            \u003cgroupId\u003eorg.springframework.boot\u003c/groupId\u003e\n            \u003cartifactId\u003espring-boot-starter\u003c/artifactId\u003e\n        \u003c/dependency\u003e\n        \u003cdependency\u003e\n            \u003cgroupId\u003evip.toby.rpc\u003c/groupId\u003e\n            \u003cartifactId\u003esimple-rpc\u003c/artifactId\u003e\n            \u003cversion\u003e3.3.2\u003c/version\u003e\n        \u003c/dependency\u003e\n    \u003c/dependencies\u003e\n\u003c/project\u003e\n```\n\n## RpcDTO\n```java\n@Data\n@RpcDTO\npublic class PlusDTO {\n\n    @NotNull\n    @Min(1)\n    private Integer x;\n\n    private int y;\n\n}\n\n@Data\n@RpcDTO\npublic class DelayPlusDTO extends RpcDelayDTO {\n\n    @NotNull\n    private Long createTime;\n\n    @NotNull\n    @Min(1)\n    private Integer x;\n\n    private int y;\n\n}\n```\n\n## RpcClientConfig\n```java\n@Component\npublic class RpcClientConfig implements RpcClientConfigurer {\n\n    @Override\n    public void addRpcClientRegistry(RpcClientRegistry rpcClientRegistry) {\n        // 如果 @RpcClient 不在当前项目，可以手动配置\n        rpcClientRegistry.addRegistration(OtherSyncClient.class);\n    }\n\n}\n```\n\n## RpcServer Demo\n```java\n@RpcServer(value = \"rpc-queue-name\", type = {RpcType.SYNC, RpcType.ASYNC}, xMessageTTL = 1000, threadNum = 1)\npublic class Server {\n\n    @RpcServerMethod\n    public R methodName1(@Validated PlusDTO plusDTO) {\n        final int x = plusDTO.getX();\n        final int y = plusDTO.getY();\n        return R.okResult(x + y);\n    }\n\n    @RpcServerMethod(\"methodName2-alias\")\n    public R methodName2(@Validated PlusDTO plusDTO) {\n        return R.failMessage(\"计算失败\").errorCode(-9999);\n    }\n\n}\n\n@RpcServer(value = \"rpc-queue-name-other\", type = RpcType.SYNC)\npublic class OtherServer {\n\n    @RpcServerMethod\n    public R methodName3(PlusDTO plusDTO) {\n        final int x = plusDTO.getX();\n        final int y = plusDTO.getY();\n        return R.okResult(x + y).message(\"计算成功, x: {}, y: {}\", x, y);\n    }\n\n}\n\n@RpcServer(value = \"delay-plus\", type = RpcType.DELAY)\n@Slf4j\npublic class DelayPlusServer {\n\n    @RpcServerMethod\n    public R delayPlus(@Validated DelayPlusDTO delayPlusDTO) {\n        final int x = delayPlusDTO.getX();\n        final int y = delayPlusDTO.getY();\n        final int delay = delayPlusDTO.getDelay();\n        final long createTime = delayPlusDTO.getCreateTime();\n        final long now = System.currentTimeMillis();\n        log.info(\"delayPlusDTO: {}, result: {}, delay: {}, duration: {}\", delayPlusDTO, x + y, delay, now - createTime);\n        return R.ok();\n    }\n\n}\n```\n\n## RpcClient Demo\n```java\n@RpcClient(value = \"rpc-queue-name\", type = RpcType.SYNC)\npublic interface SyncClient {\n\n    @RpcClientMethod\n    RpcResult methodName1(PlusDTO plusDTO);\n\n    @RpcClientMethod(\"methodName2-alias\")\n    RpcResult methodName2(PlusDTO plusDTO);\n\n}\n\n@RpcClient(value = \"rpc-queue-name\", type = RpcType.ASYNC)\npublic interface AsyncClient {\n\n    @RpcClientMethod\n    void methodName1(PlusDTO plusDTO);\n\n    @RpcClientMethod(\"methodName2-alias\")\n    void methodName2(PlusDTO plusDTO);\n\n}\n\n@RpcClient(value = \"rpc-queue-name-other\", type = RpcType.SYNC)\npublic interface OtherSyncClient {\n\n    @RpcClientMethod\n    RpcResult methodName3(PlusDTO plusDTO);\n\n}\n\n@RpcClient(value = \"delay-plus\", type = RpcType.DELAY)\npublic interface DelayClient {\n\n    @RpcClientMethod\n    void delayPlus(DelayPlusDTO delayPlusDTO);\n\n}\n```\n\n## Application Demo\n```java\n@EnableSimpleRpc\n@SpringBootApplication\n@RequiredArgsConstructor\n@Slf4j\npublic class Application {\n\n    private final AsyncClient asyncClient;\n    private final SyncClient syncClient;\n    private final OtherSyncClient otherSyncClient;\n    private final DelayClient delayClient;\n\n    public static void main(String[] args) {\n        SpringApplication.run(Application.class, args);\n    }\n\n    @PostConstruct\n    public void test() {\n        new Thread(() -\u003e {\n\n            try {\n                Thread.sleep(1000);\n            } catch (InterruptedException e) {\n                log.error(e.getMessage(), e);\n            }\n\n            // 同步调用 1\n            final PlusDTO plusDTO = new PlusDTO();\n            plusDTO.setX(1);\n            plusDTO.setY(1);\n            RpcResult rpcResult = syncClient.methodName1(plusDTO);\n            log.info(\"syncClient.methodName1, RStatusOk: {}, RResult: {}\", rpcResult.isRStatusOk(), rpcResult.getRResult());\n\n            // 同步调用 1-1\n            plusDTO.setX(0);\n            rpcResult = syncClient.methodName1(plusDTO);\n            log.info(\"syncClient.methodName1, RStatusOk: {}, ErrorMessage: {}, ErrorCode: {}\", rpcResult.isRStatusOk(), rpcResult.getResult()\n                    .getMessage(), rpcResult.getResult().getErrorCode());\n\n            // 同步调用 2\n            plusDTO.setX(2);\n            rpcResult = syncClient.methodName2(plusDTO);\n            log.info(\"syncClient.methodName2, RStatusOk: {}, ErrorMessage: {}, ErrorCode: {}\", rpcResult.isRStatusOk(), rpcResult.getResult()\n                    .getMessage(), rpcResult.getResult().getErrorCode());\n\n            // 异步调用\n            asyncClient.methodName2(plusDTO);\n\n            // 同步调用 3\n            rpcResult = otherSyncClient.methodName3(plusDTO);\n            log.info(\"otherSyncClient.methodName3, RStatusOk: {}, RResult: {}\", rpcResult.isRStatusOk(), rpcResult.getRResult());\n\n            // 延迟调用, 注意⚠️ RabbitMQ 需要启用插件 https://github.com/rabbitmq/rabbitmq-delayed-message-exchange\n            final DelayPlusDTO delayPlusDTO = new DelayPlusDTO();\n            delayPlusDTO.setCreateTime(System.currentTimeMillis());\n            // 延迟 3 秒后调用\n            delayPlusDTO.setDelay(3000);\n            delayPlusDTO.setX(5);\n            delayPlusDTO.setY(8);\n            delayClient.delayPlus(delayPlusDTO);\n\n        }).start();\n    }\n\n}\n```\n\n## Demo 源码\nhttps://github.com/naivetoby/simple-rpc-demo\n\n## application.yml 配置\n```yaml\nspring:\n  rabbitmq:\n    host: 127.0.0.1\n    port: 5672\n    username: admin\n    password: admin\n    virtual-host: default_vs\n```\n\n## 许可证\n\n[![license](https://img.shields.io/github/license/naivetoby/simple-rpc.svg?style=flat-square)](https://github.com/naivetoby/simple-rpc/blob/main/LICENSE)\n\n使用 Apache License - Version 2.0 协议开源。\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnaivetoby%2Fsimple-rpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnaivetoby%2Fsimple-rpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnaivetoby%2Fsimple-rpc/lists"}