• Stars
    star
    2,354
  • Rank 19,543 (Top 0.4 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created over 9 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Java implementation of RSocket

RSocket

Join the chat at https://gitter.im/RSocket/RSocket-Java

RSocket is a binary protocol for use on byte stream transports such as TCP, WebSockets, and Aeron.

It enables the following symmetric interaction models via async message passing over a single connection:

  • request/response (stream of 1)
  • request/stream (finite stream of many)
  • fire-and-forget (no response)
  • event subscription (infinite stream of many)

Learn more at http://rsocket.io

Build and Binaries

Build Status

⚠️ The master branch is now dedicated to development of the 1.2.x line.

Releases and milestones are available via Maven Central.

Example:

repositories {
    mavenCentral()
    maven { url 'https://repo.spring.io/milestone' }  // Reactor milestones (if needed)
}
dependencies {
    implementation 'io.rsocket:rsocket-core:1.2.0-SNAPSHOT'
    implementation 'io.rsocket:rsocket-transport-netty:1.2.0-SNAPSHOT'
}

Snapshots are available via oss.jfrog.org (OJO).

Example:

repositories {
    maven { url 'https://maven.pkg.github.com/rsocket/rsocket-java' }
    maven { url 'https://repo.spring.io/snapshot' }  // Reactor snapshots (if needed)
}
dependencies {
    implementation 'io.rsocket:rsocket-core:1.2.0-SNAPSHOT'
    implementation 'io.rsocket:rsocket-transport-netty:1.2.0-SNAPSHOT'
}

Development

Install the google-java-format in Intellij, from Plugins preferences. Enable under Preferences -> Other Settings -> google-java-format Settings

Format automatically with

$./gradlew goJF

Debugging

Frames can be printed out to help debugging. Set the logger io.rsocket.FrameLogger to debug to print the frames.

Requirements

Trivial Client

package io.rsocket.transport.netty;

import io.rsocket.Payload;
import io.rsocket.RSocket;
import io.rsocket.core.RSocketConnector;
import io.rsocket.transport.netty.client.WebsocketClientTransport;
import io.rsocket.util.DefaultPayload;
import reactor.core.publisher.Flux;

import java.net.URI;

public class ExampleClient {
    public static void main(String[] args) {
        WebsocketClientTransport ws = WebsocketClientTransport.create(URI.create("ws://rsocket-demo.herokuapp.com/ws"));
        RSocket clientRSocket = RSocketConnector.connectWith(ws).block();

        try {
            Flux<Payload> s = clientRSocket.requestStream(DefaultPayload.create("peace"));

            s.take(10).doOnNext(p -> System.out.println(p.getDataUtf8())).blockLast();
        } finally {
            clientRSocket.dispose();
        }
    }
}

Zero Copy

By default to make RSocket easier to use it copies the incoming Payload. Copying the payload comes at cost to performance and latency. If you want to use zero copy you must disable this. To disable copying you must include a payloadDecoder argument in your RSocketFactory. This will let you manage the Payload without copying the data from the underlying transport. You must free the Payload when you are done with them or you will get a memory leak. Used correctly this will reduce latency and increase performance.

Example Server setup

RSocketServer.create(new PingHandler())
        // Enable Zero Copy
        .payloadDecoder(PayloadDecoder.ZERO_COPY)
        .bind(TcpServerTransport.create(7878))
        .block()
        .onClose()
        .block();

Example Client setup

RSocket clientRSocket =
        RSocketConnector.create()
            // Enable Zero Copy
            .payloadDecoder(PayloadDecoder.ZERO_COPY)
            .connect(TcpClientTransport.create(7878))
            .block();

Bugs and Feedback

For bugs, questions and discussions please use the Github Issues.

LICENSE

Copyright 2015-2020 the original author or authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

More Repositories

1

rsocket

RSocket Protocol Definition
1,837
star
2

rsocket-js

JavaScript implementation of RSocket
TypeScript
593
star
3

rsocket-kotlin

RSocket Kotlin multi-platform implementation
Kotlin
545
star
4

rsocket-go

rsocket-go implementation
Go
504
star
5

rsocket-cpp

C++ implementation of RSocket
C++
253
star
6

rsocket-net

.NET implementation of RSocket
C#
251
star
7

rsocket-rust

RSocket Rust Implementation using Tokio
Rust
205
star
8

rsocket-rpc-java

Standard RSocket RPC Java Implementation
Java
172
star
9

rsocket-swift

Swift implementation of RSocket Protocol
Swift
76
star
10

rsocket-py

RSocket implementation in Python
Python
76
star
11

rsocket-cli

Command-line client for ReactiveSocket
Kotlin
71
star
12

rsocket-chrome-devtools

RSocket Chrome Dev Tools
TypeScript
42
star
13

rsocket-dart

Dart implementation of RSocket
Dart
31
star
14

rsocket-rpc-js

Standard RSocket RPC Implementation
JavaScript
29
star
15

rsocket-transport-akka

Akka TCP and WebSocket transports for RSocket
Java
28
star
16

rsocket-demo-android-java8

RSocket Android Demo
Kotlin
23
star
17

rsocket-wireshark

Wireshark Plugin for RSocket
C
19
star
18

rsocket-rpc-kotlin

Standard RSocket RPC Kotlin Implementation
Kotlin
19
star
19

rsocket-rpc-net

Standard RSocket RPC .NET Implementation
C#
17
star
20

rsocket-rpc-go

RSocket RPC Golang
Go
15
star
21

rsocket-php

RSocket PHP implementation using ReactPHP
PHP
10
star
22

rsocket-tck

Technology Compatibility Kit (TCK) for RSocket implementations
Kotlin
10
star
23

rsocket-transport-aeron

Aeron Transport for RSocket
Java
10
star
24

ewma

Exponentially Weighted Moving Average
JavaScript
10
star
25

rsocket-rb

Ruby
8
star
26

rsocket-website

rsocket.io website
MDX
7
star
27

bomberman-workshop

JavaScript
7
star
28

rsocket-jmeter

RSocket JMeter Plugin
Java
3
star
29

tsc

RSocket Technical Steering Committee (TSC)
3
star
30

rsocket-c

C implementation of RSocket
3
star
31

rsocket-tck-server

RSocket TCK Server
Kotlin
2
star
32

gradle-nebula-plugin-rsocket

Groovy
1
star
33

rsocket-artwork

RSocket Logos
1
star
34

.github

Template repository for rsocket projects, includes typical README + labels
1
star