Reactor-Netty with pipeline

84 views
Skip to first unread message

Phillip Gibb

unread,
May 17, 2017, 2:32:38 AM5/17/17
to Netty discussions
Has anyone been able to set up a reactor-netty tcp server with a configurable pipeline. It seems that I have to call newHandler that takes a functional interface, a BiFunction handler with NettyInbound and OutBlound. Returning anything from the handler results in a response to the client but nothing goes through the pipeline. The pipeline can be set after creating the TcpServer with afterChannelInit.

EventLoopGroup group = new NioEventLoopGroup(1);
   
try {
       
final TcpServer server = TcpServer.create(opts -> opts.afterChannelInit(clientEndPoint).listen(tcpSocketAddress));
        server
.newHandler((in, out) -> {
           
in.receive().asByteArray().map(bb -> {
               
try {
                   
return m.readValue(bb, Message.class);
               
} catch (IOException io) {
                   
throw Exceptions.propagate(io);
               
}
           
}).log("conn").subscribe(data -> {
               
if ("Hello World!".equals(data.getMessage())) {
                    latch
.countDown();
               
}
           
});
           
return Flux.never();//does not return anything to client or even pass the event to the pipeline
           
//this returns to the client: return out.sendString(Mono.just("Hi")).neverComplete();
       
}).block(Duration.ofSeconds(30));
   
} finally {
       
group.shutdownGracefully().sync();
   
}

I don't want to return anything to the client until it has gone through the pipeline.
My clientEndPoint implements Consumer<Channel> and sets up the pipeline in the accept(Channel sc) method.
The above is structured from Netty-reactor's tcpServerHandlesJsonPojosOverSsl

thanks

Phillip

Norman Maurer

unread,
May 17, 2017, 2:43:51 AM5/17/17
to ne...@googlegroups.com, Phillip Gibb
I think you should ask on the reactor mailinglist as this is not related to netty itself.
--
You received this message because you are subscribed to the Google Groups "Netty discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netty+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netty/f5c54252-b662-4c4d-9a2d-5b00ac49ba0a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages