2

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?

1 Answer 1

2

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());
Sign up to request clarification or add additional context in comments.

1 Comment

If you search github, or the spring tutorials you should find a lot of examples of this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.