Add client responder configuration

Prior to this commit, the `RSocketRequester.Builder` would allow to
configure directly annotated handlers for processing server requests.
This lead to a package tangle where the `o.s.messaging.rsocket` would
use classes from `o.s.messaging.rsocket.annotation.support` package.

This commit introduces the `ClientResponderFactory` interface for
configuring a responder on the client RSocket factory. Its goal is
to be compatible with future changes with a functional variant for
RSocket handlers.

Closes gh-23170
This commit is contained in:
Brian Clozel
2019-07-17 12:06:37 +02:00
parent d6e3394b81
commit e7ecb83449
5 changed files with 224 additions and 31 deletions

View File

@@ -42,6 +42,7 @@ import org.springframework.core.codec.StringDecoder;
import org.springframework.core.io.buffer.NettyDataBufferFactory;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.rsocket.annotation.ConnectMapping;
import org.springframework.messaging.rsocket.annotation.support.ClientResponderFactory;
import org.springframework.messaging.rsocket.annotation.support.RSocketMessageHandler;
import org.springframework.stereotype.Controller;
@@ -102,17 +103,22 @@ public class RSocketServerToClientIntegrationTests {
ServerController serverController = context.getBean(ServerController.class);
serverController.reset();
RSocketStrategies rSocketStrategies = context.getBean(RSocketStrategies.class);
ClientResponderFactory clientResponder = ClientResponderFactory.create()
.strategies(rSocketStrategies)
.handlers(new ClientHandler());
RSocketRequester requester = null;
try {
requester = RSocketRequester.builder()
.annotatedHandlers(new ClientHandler())
.rsocketFactory(factory -> {
factory.metadataMimeType("text/plain");
factory.setupPayload(ByteBufPayload.create("", connectionRoute));
factory.frameDecoder(PayloadDecoder.ZERO_COPY);
})
.rsocketStrategies(context.getBean(RSocketStrategies.class))
.rsocketFactory(clientResponder)
.rsocketStrategies(rSocketStrategies)
.connectTcp("localhost", server.address().getPort())
.block();