private final RSocketRequester rSocketRequester;
@RequestMapping(path = "/**")
public Publisher<ServerResponse> mockController(ServerWebExchange serverWebExchange) {
String path = serverWebExchange.getRequest().getPath().toString();
String method = serverWebExchange.getRequest().getMethodValue();
return rSocketRequester.route("/mock").data(path).data(method).retrieveMono(ServerResponse.class);
}
@MessageMapping(value = "/mock")
public Mono<ServerResponse> mockService(String path, String method) {
return Mono.just(new ServerResponse<>(0, "success", path+method));
}
Rsocket にさらにパラメーターを設定すると、Controller を要求したときに Rsocket がエラーを報告する
java.lang.NullPointerException: null
at io.rsocket.util.ByteBufPayload.sliceData(ByteBufPayload.java:149) ~[rsocket-core-1.0.0-RC5.jar:na]
at org.springframework.messaging.rsocket.PayloadUtils.retainDataAndReleasePayload(PayloadUtils.java:54) ~[spring-messaging-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.messaging.rsocket.annotation.support.MessagingRSocket.retainDataAndReleasePayload(MessagingRSocket.java:186) ~[spring-messaging-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:107) ~[reactor-core-3.3.0.RELEASE.jar:3.3.0.RELEASE]
at reactor.core.publisher.FluxJust$WeakScalarSubscription.request(FluxJust.java:99) ~[reactor-core-3.3.0.RELEASE.jar:3.3.0.RELEASE]
at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.request(FluxMapFuseable.java:162) ~[reactor-core-3.3.0.RELEASE.jar:3.3.0.RELEASE]
at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.request(FluxPeekFuseable.java:137) ~[reactor-core-3.3.0.RELEASE.jar:3.3.0.RELEASE]
それを解決する方法は?これは私の rsocket-controller 構成ですが、構成の問題でしょうか?
@Bean
RSocket rSocket() {
return RSocketFactory
.connect()
.dataMimeType(MimeTypeUtils.ALL_VALUE)
.frameDecoder(PayloadDecoder.ZERO_COPY)
.transport(TcpClientTransport.create(7003))
.start()
.block();
}
@Bean
RSocketRequester rSocketRequester(RSocketStrategies rSocketStrategies) {
return RSocketRequester.builder()
.rsocketFactory(factory -> factory
.dataMimeType(MimeTypeUtils.ALL_VALUE)
.frameDecoder(PayloadDecoder.ZERO_COPY))
.rsocketStrategies(rSocketStrategies)
.connect(TcpClientTransport.create(7003))
.retry().block();
}