Converting a Webflux Request Into an RSocket Request/Response
Explore how to connect a Spring WebFlux HTTP POST request to an RSocket request/response method in Spring Boot. Understand the reactive flow from receiving the request to forwarding it over RSocket and handling the response. Learn to write integration tests using WebTestClient and MongoDB clearance to validate the client-server interaction within a reactive programming model.
Forwarding Item using request/response
Check out the code below to see how we can connect an incoming HTTP POST with WebFlux to our RSocket request/response method on the server.
Here’s a breakdown of the code above:
-
In line 1,
@PostMapping(...)indicates that this Spring WebFlux method acceptsHTTP POSTrequests at the/items/request-responseroute. -
In line 5, we can
route()this request to the destinationnewItems.request-responseby flat mapping over theMono<RSocketRequestor>. -
In line 6, we submit the payload of the
Itemobject in thedata()method. -
In line 7, we signal that we ...