Reactive Streams Support #244
Labels
API (Both)
Impacts the client and server API
enhancement
Adding a new feature or improving an existing one
Milestone
Reactive Streams, also known as the JDK9 juc.Flow API, allows developers to plumb asynchronous streams of messages between libraries, in a way that safely ensures that backpressure, error and completion handling are correctly propagated through the streams. Providing support for Reactive Streams in the WebSocket spec would allow JSR356 WebSocket implementations to participate in this rich and growing ecosystem of asynchronous streaming libraries.
Use cases include plumbing WebSocket connections together, plumbing message broker subscribers and publishers into WebSocket streams, and integration with dedicated streaming libraries such as Akka, Reactor and RxJava, to allow developers to create complex graphs of streams.
As an example of what reactive streams support could look like, here's what it might look like to build a chat room using Kafka (using a Kafka reactive streams client such as https://github.com/unicredit/kafka-reactive-streams) as the backend for publishing and subscribing to messages:
All the WebSocket specific code relating to plumbing messages, back pressure, and stream error handling can be seen in the
connectToRoom
method, which is invoked when the WebSocket is connected. The passed inincomingMessages
publisher is the incoming WebSocket stream, each message being a chat message to publish to the room, while the returned Publisher is a stream of all the messages published to the chat room.The text was updated successfully, but these errors were encountered: