{"id":13694533,"url":"https://github.com/rsocket/rsocket-java","last_synced_at":"2025-05-14T07:07:54.598Z","repository":{"id":34751415,"uuid":"38732107","full_name":"rsocket/rsocket-java","owner":"rsocket","description":"Java implementation of RSocket","archived":false,"fork":false,"pushed_at":"2025-02-10T08:21:56.000Z","size":6288,"stargazers_count":2365,"open_issues_count":56,"forks_count":355,"subscribers_count":105,"default_branch":"master","last_synced_at":"2025-05-07T06:59:08.933Z","etag":null,"topics":["aeron","java","netty","reactive","reactor-core","rsocket","rxjava","stream"],"latest_commit_sha":null,"homepage":"http://rsocket.io","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/rsocket.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":"CONTRIBUTING.md","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":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-07-08T04:36:42.000Z","updated_at":"2025-05-03T06:23:19.000Z","dependencies_parsed_at":"2024-01-14T19:12:15.957Z","dependency_job_id":"089f7189-becc-4dc5-812e-e4234542c23d","html_url":"https://github.com/rsocket/rsocket-java","commit_stats":{"total_commits":1114,"total_committers":75,"mean_commits":"14.853333333333333","dds":0.8321364452423698,"last_synced_commit":"6e5917909e26e89305123d9a457d75c369c7acc9"},"previous_names":["reactivesocket/reactivesocket-java"],"tags_count":97,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsocket%2Frsocket-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsocket%2Frsocket-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsocket%2Frsocket-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsocket%2Frsocket-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rsocket","download_url":"https://codeload.github.com/rsocket/rsocket-java/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254092650,"owners_count":22013290,"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":["aeron","java","netty","reactive","reactor-core","rsocket","rxjava","stream"],"created_at":"2024-08-02T17:01:34.260Z","updated_at":"2025-05-14T07:07:54.488Z","avatar_url":"https://github.com/rsocket.png","language":"Java","readme":"# RSocket\n\n[![Join the chat at https://gitter.im/RSocket/RSocket-Java](https://badges.gitter.im/rsocket/rsocket-java.svg)](https://gitter.im/rsocket/rsocket-java)\n\nRSocket is a binary protocol for use on byte stream transports such as TCP, WebSockets, and Aeron.\n\nIt enables the following symmetric interaction models via async message passing over a single connection:\n\n- request/response (stream of 1)\n- request/stream (finite stream of many)\n- fire-and-forget (no response)\n- event subscription (infinite stream of many)\n\nLearn more at http://rsocket.io\n\n## Build and Binaries\n\n[![Build Status](https://github.com/rsocket/rsocket-java/actions/workflows/gradle-main.yml/badge.svg?branch=master)](https://github.com/rsocket/rsocket-java/actions/workflows/gradle-main.yml)\n\n⚠️ The `master` branch is now dedicated to development of the `1.2.x` line.\n\nReleases and milestones are available via Maven Central.\n\nExample:\n\n```groovy\nrepositories {\n    mavenCentral()\n    maven { url 'https://repo.spring.io/milestone' }  // Reactor milestones (if needed)\n}\ndependencies {\n    implementation 'io.rsocket:rsocket-core:1.2.0-SNAPSHOT'\n    implementation 'io.rsocket:rsocket-transport-netty:1.2.0-SNAPSHOT'\n}\n```\n\nSnapshots are available via [oss.jfrog.org](oss.jfrog.org) (OJO).\n\nExample:\n\n```groovy\nrepositories {\n    maven { url 'https://maven.pkg.github.com/rsocket/rsocket-java' }\n    maven { url 'https://repo.spring.io/snapshot' }  // Reactor snapshots (if needed)\n}\ndependencies {\n    implementation 'io.rsocket:rsocket-core:1.2.0-SNAPSHOT'\n    implementation 'io.rsocket:rsocket-transport-netty:1.2.0-SNAPSHOT'\n}\n```\n\n\n## Development\n\nInstall the google-java-format in Intellij, from Plugins preferences.\nEnable under Preferences -\u003e Other Settings -\u003e google-java-format Settings\n\nFormat automatically with\n\n```\n$./gradlew goJF\n```\n\n## Debugging\nFrames can be printed out to help debugging. Set the logger `io.rsocket.FrameLogger` to debug to print the frames.\n\n## Requirements\n\n- Java 8 - heavy dependence on Java 8 functional APIs and java.time, also on Reactor\n- Android O - https://github.com/rsocket/rsocket-demo-android-java8\n\n## Trivial Client\n\n```java\npackage io.rsocket.transport.netty;\n\nimport io.rsocket.Payload;\nimport io.rsocket.RSocket;\nimport io.rsocket.core.RSocketConnector;\nimport io.rsocket.transport.netty.client.WebsocketClientTransport;\nimport io.rsocket.util.DefaultPayload;\nimport reactor.core.publisher.Flux;\n\nimport java.net.URI;\n\npublic class ExampleClient {\n    public static void main(String[] args) {\n        WebsocketClientTransport ws = WebsocketClientTransport.create(URI.create(\"ws://rsocket-demo.herokuapp.com/ws\"));\n        RSocket clientRSocket = RSocketConnector.connectWith(ws).block();\n\n        try {\n            Flux\u003cPayload\u003e s = clientRSocket.requestStream(DefaultPayload.create(\"peace\"));\n\n            s.take(10).doOnNext(p -\u003e System.out.println(p.getDataUtf8())).blockLast();\n        } finally {\n            clientRSocket.dispose();\n        }\n    }\n}\n```\n\n## Zero Copy\nBy default to make RSocket easier to use it copies the incoming Payload. Copying the payload comes at cost to performance\nand latency. If you want to use zero copy you must disable this. To disable copying you must include a `payloadDecoder`\nargument in your `RSocketFactory`. This will let you manage the Payload without copying the data from the underlying\ntransport. You must free the Payload when you are done with them\nor you will get a memory leak. Used correctly this will reduce latency and increase performance.\n\n### Example Server setup\n```java\nRSocketServer.create(new PingHandler())\n        // Enable Zero Copy\n        .payloadDecoder(PayloadDecoder.ZERO_COPY)\n        .bind(TcpServerTransport.create(7878))\n        .block()\n        .onClose()\n        .block();\n```\n\n### Example Client setup\n```java\nRSocket clientRSocket =\n        RSocketConnector.create()\n            // Enable Zero Copy\n            .payloadDecoder(PayloadDecoder.ZERO_COPY)\n            .connect(TcpClientTransport.create(7878))\n            .block();\n```\n\n## Bugs and Feedback\n\nFor bugs, questions and discussions please use the [Github Issues](https://github.com/RSocket/reactivesocket-java/issues).\n\n## LICENSE\n\nCopyright 2015-2020 the original author or authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","funding_links":[],"categories":["Java","并发编程","\u003ca name=\"Java\"\u003e\u003c/a\u003eJava"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frsocket%2Frsocket-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frsocket%2Frsocket-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frsocket%2Frsocket-java/lists"}