如何解决Java RSocket 客户端与 Spring RSocket 通道连接
我有简单的 Spring Boot RSocket 服务
@MessageMapping("msend")
public Flux<String> msend(String message) {
log.info("msend channel publish " + message);
return Flux.just(message," "+System.currentTimeMillis());
}
很容易连接2个Spring服务,但是我的客户端应用没有spring,我的客户端应该是RSocket java
我很难理解如何向该特定通道发送(路由,如 Spring RsocketRequester)消息。
客户端代码应该是:
Mono<RSocket> rsocket = RSocketConnector.create()
.metadataMimeType(WellKnownMimeType.MESSAGE_RSOCKET_COMPOSITE_METADATA.getString())
.connect(TcpClientTransport.create(2050));
///real path "http://gateway:2022/producer/toProducerRsocket",2050)
///toProducerRsocket redirect to producer/rsocket
是否可以订阅 Spring 频道?
解决方法
这对于定义元数据类型来说看起来是正确的。但是您需要为请求流设置它。此处的频道听起来不正确,因为您只有一个输入值消息。
https://stackoverflow.com/a/62776146/1542667
CompositeByteBuf metadata = ByteBufAllocator.DEFAULT.compositeBuffer();
RoutingMetadata routingMetadata = TaggingMetadataCodec.createRoutingMetadata(ByteBufAllocator.DEFAULT,List.of("/route"));
CompositeMetadataCodec.encodeAndAddMetadata(metadata,ByteBufAllocator.DEFAULT,WellKnownMimeType.MESSAGE_RSOCKET_ROUTING,routingMetadata.getContent());
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。