Reputation: 2043
I have simple Spring boot RSocket service
@MessageMapping("msend")
public Flux<String> msend(String message) {
log.info("msend channel publish " + message);
return Flux.just(message, " "+System.currentTimeMillis());
}
It is easy to connect 2 Spring services, but my client application does not have spring, my client should be in RSocket java
I have difficulty to understand how to send (route, like Spring RsocketRequester) messages to that specific channel.
client code should be:
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
Is it possible subscribe Spring channels?
Upvotes: 2
Views: 916
Reputation: 13458
That looks correct for defining the metadata type. But you need to set it for the request stream. Channel doesn't sound correct here since you have a single input value message.
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());
Upvotes: 2