Introduction

RSocket translates to Reactive socket is a messaging protocol that works over TCP or Websockets. Communication modes this protocol provides are fire-and-forget, request-response and streaming. Since RSocket is fully reactive, it’s ideal for high-throughput applications.

In this post, we will explore three communications modes which are fire-and-forgetrequest-response and streaming and test with RSocket Client CLI (RSC) a postman type application but to test application over the socket.

Setup

  1. Install Java preferably version 15.
  2. Spring boot skeleton project
  3. Navigate to start.spring.io, select RSocket as a dependency and a stable version of spring boot version at the point of time and clicking on Generate should give a zip file with a skeleton project which good to get going.

Image for post

Initial project structure looks as

Image for post

  1. Application configuration
  2. Next, setting up the port on which this application runs by modifying the file application.properties
spring.rsocket.server.port=7000
spring.main.lazy-initialization=true
  1. Client to test the server application:
  2. Here I am using RSC client created by Toshiaki Maki. Set-up instructions are on his GitHub page.

#socket-programming #java #spring #reactive-programming #rxjava

Building an RSocket based Springboot application
1.35 GEEK