{"id":50413961,"url":"https://github.com/sunquakes/jsonrpc4j","last_synced_at":"2026-05-31T05:02:33.301Z","repository":{"id":38015300,"uuid":"458213528","full_name":"sunquakes/jsonrpc4j","owner":"sunquakes","description":"A java client and server over http or tcp implementation of JSON-RPC 2.0. Support consul \u0026 nacos.","archived":false,"fork":false,"pushed_at":"2024-10-19T05:44:27.000Z","size":537,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-15T06:52:29.754Z","etag":null,"topics":["client","consul","http","java","jsonrpc","jsonrpc2","nacos","netty","rpc","server","springboot","tcp"],"latest_commit_sha":null,"homepage":"https://www.moonquakes.io/guide/java.html","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sunquakes.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}},"created_at":"2022-02-11T14:13:11.000Z","updated_at":"2024-10-19T05:32:53.000Z","dependencies_parsed_at":"2023-11-08T13:36:33.051Z","dependency_job_id":"3c0d1288-4cc7-4df0-b5a2-08147f41bf74","html_url":"https://github.com/sunquakes/jsonrpc4j","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/sunquakes/jsonrpc4j","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunquakes%2Fjsonrpc4j","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunquakes%2Fjsonrpc4j/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunquakes%2Fjsonrpc4j/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunquakes%2Fjsonrpc4j/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sunquakes","download_url":"https://codeload.github.com/sunquakes/jsonrpc4j/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunquakes%2Fjsonrpc4j/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33719601,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-31T02:00:06.040Z","response_time":95,"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":["client","consul","http","java","jsonrpc","jsonrpc2","nacos","netty","rpc","server","springboot","tcp"],"created_at":"2026-05-31T05:02:32.294Z","updated_at":"2026-05-31T05:02:33.283Z","avatar_url":"https://github.com/sunquakes.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"English | [🇨🇳中文](README_ZH.md)\n\n# jsonrpc4j\n\n\u003cp align=\"center\"\u003e\u003ca href=\"https://moonquakes.io/\" target=\"_blank\" rel=\"noopener noreferrer\"\u003e\u003cimg width=\"200\" src=\"https://www.moonquakes.io/images/logo.png\" alt=\"moonquakes logo\"\u003e\u003c/a\u003e\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n    \u003cimg alt=\"jdk\" src=\"https://img.shields.io/badge/jdk-%3E%3D17-red\"\u003e\n    \u003ca href=\"https://github.com/sunquakes/jsonrpc4j\"\u003e\u003cimg alt=\"Maven Central\" src=\"https://img.shields.io/maven-central/v/com.sunquakes/jsonrpc4j\"\u003e\u003c/a\u003e\n    \u003cimg alt=\"GitHub\" src=\"https://img.shields.io/github/license/sunquakes/jsonrpc4j?color=blue\"\u003e\n\u003c/p\u003e \n\n## Installing\n\n- Add maven source to the pom.xml\n\n```xml\n\n\u003crepositories\u003e\n    \u003crepository\u003e\n        \u003cid\u003ereleases\u003c/id\u003e\n        \u003cname\u003eReleases\u003c/name\u003e\n        \u003curl\u003ehttps://oss.sonatype.org/content/repositories/releases/\u003c/url\u003e\n    \u003c/repository\u003e\n    \u003crepository\u003e\n        \u003cid\u003esnapshots\u003c/id\u003e\n        \u003cname\u003eSnapshots\u003c/name\u003e\n        \u003curl\u003ehttps://oss.sonatype.org/content/repositories/snapshots/\u003c/url\u003e\n    \u003c/repository\u003e\n\u003c/repositories\u003e\n```\n\n- Add dependency to the pom.xml\n\n```xml\n\u003c!-- https://mvnrepository.com/artifact/com.sunquakes/jsonrpc4j --\u003e\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.sunquakes\u003c/groupId\u003e\n    \u003cartifactId\u003ejsonrpc4j\u003c/artifactId\u003e\n    \u003cversion\u003e3.0.0-SNAPSHOT\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## Getting started\n\n### step1. Configuring base packages with @JsonRpcScan to scan service and client class\n\n- method 1. Used with the @Configuration\n\n```java\n\n@Configuration\n@JsonRpcScan({\"com.sunquakes\"})\npublic class JsonRpcConfig {\n}\n```\n\n- method 2. Used in the Application class\n\n```java\n\n@SpringBootApplication\n@JsonRpcScan({\"com.sunquakes.jsonrpc4j.spring.boot\"})\npublic class JsonRpcApplication {\n    public static void main(String[] args) {\n        SpringApplication.run(JsonRpcApplication.class, args);\n    }\n}\n```\n\n### step2. Configuring server\n\n- Add configuration items to application.properties\n\n```properties\n# The protocol of the server, Value can be tcp or http.\njsonrpc.server.protocol=tcp\n# The port of the server listening.\njsonrpc.server.port=3200\n# If the protocol is http, the next two property can be ignore.\n# Symbol for the end of data receive once.\njsonrpc.server.package-eof=\\r\\n\n# Buffer size of the server receive data.\njsonrpc.server.package-max-length=2097152\n```\n\n### step3. Create service interface and class\n\n- Create a new interface file named IJsonRpcService with @JsonRpcService, value is the name of the service\n\n```java\n\n@JsonRpcService(value = \"JsonRpc\")\npublic interface IJsonRpcService {\n    int add(int a, int b);\n}\n```\n\n- Create a new class file name JsonRpcServiceImpl to implements interface IJsonRpcService\n\n```java\npublic class JsonRpcServiceImpl implements IJsonRpcService {\n    @Override\n    public Integer add(int a, int b) {\n        return a + b;\n    }\n}\n```\n\n### step4. Configuring client\n\n- Add configuration items to application.properties\n\n```properties\n# Symbol for the end of data request once.\njsonrpc.client.package-eof=\\r\\n\n```\n\n### step5. Create client interface\n\n- Create a new interface file named IJsonRpcClient with @JsonRpcClient, protocol can be tcp or http or https and should\n  be same as item(jsonrpc.server.protocol) of step2, value must be same as the value of step3.\n\n```java\n\n@JsonRpcClient(value = \"JsonRpc\", protocol = JsonRpcProtocol.TCP, url = \"localhost:3200\")\npublic interface IJsonRpcClient {\n    int add(int a, int b);\n}\n```\n\n### step6. Use the client request the server\n\n```java\npublic class JsonRpcTest {\n\n    @Autowired\n    private IJsonRpcClient jsonRpcClient;\n\n    public int add() {\n        // data sent: {\"id\":\"691bbf41-e992-4f45-9c0d-1eeb0b088698\",\"jsonrpc\":\"2.0\",\"method\":\"json_rpc/add\",\"params\":{\"a\":3,\"b\":4}}\n        // data received: {\"id\":\"691bbf41-e992-4f45-9c0d-1eeb0b088698\",\"jsonrpc\":\"2.0\",\"result\":7}\n        return jsonRpcClient.add(1, 2); // the result is 3\n    }\n}\n```\n\n## More Feature\n\n### Service Discovery\n\n- Consul\n\n```properties\n# The service hostname, not required, if the default node ip is used, it can be ignored.\njsonrpc.discovery.hostname=192.168.39.1\n# The consul address\n# instanceId: If there are the same service has same service name and port in difference nodes, the parameter is required. \n# check: true is enable health check. The default value is false\n# checkInterval: If the check parameter is true, the parameter valid. The default value is 60s\njsonrpc.discovery.url=http://127.0.0.1:8500?instanceId=2\u0026check=true\u0026checkInterval=5s\n# The consul driver\njsonrpc.discovery.driver-name=com.sunquakes.jsonrpc4j.discovery.Consul\n```\n\n- Nacos\n\n```properties\n# The service hostname, not required, if the default node ip is used, it can be ignored.\njsonrpc.discovery.hostname=192.168.39.1\n# The nacos address\n# Support [Open API Guide](https://nacos.io/en-us/docs/open-api.html) Register instance chapter Request Parameters.\njsonrpc.discovery.url=http://127.0.0.1:8849?namespaceId=XXXXXX\u0026...\n# The nacos driver\njsonrpc.discovery.driver-name=com.sunquakes.jsonrpc4j.discovery.Nacos\n```\n\n## Test\n\n```shell\nmvn test\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsunquakes%2Fjsonrpc4j","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsunquakes%2Fjsonrpc4j","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsunquakes%2Fjsonrpc4j/lists"}