...

/

Converting a Webflux Request Into an RSocket Channel

Converting a Webflux Request Into an RSocket Channel

Learn how to listen for new events over an RSocket using a channel.

We'll cover the following...

Listening for new events

Having covered the two paradigms RSocket offers for 1-to-1 send-receive, we can now move into the really cool stuff. Namely, RSocket’s support for a bidirectional channel.

The following example sends a single message to subscribe to a flow of events:

@GetMapping(value = "/items", produces = TEXT_EVENT_STREAM_VALUE) //1
Flux<Item> liveUpdates() {
return this.requester
.flatMapMany(rSocketRequester -> rSocketRequester
.route("newItems.monitor") //2
.retrieveFlux(Item.class)); //3
}
Listening for new events over an RSocket using a channel

Here’s a breakdown of the code above:

  1. In line 1, @GetMapping denotes that this method is used to receive traffic, not alter the system. ...