How to add a ChannelInitializer to TcpServer in reactor netty

I have a NettyServerCustomizer which next code:

@Override
    public HttpServer apply(final HttpServer httpServer) {
        return httpServer.tcpConfiguration(tcpServer -> tcpServer
            .bootstrap(serverBootstrap -> serverBootstrap
                .childHandler(new ChannelInitializer<SocketChannel>() {
                    @Override
                    public void initChannel(final SocketChannel ch) throws Exception {
                        final ChannelPipeline p = ch.pipeline();
                        p.addFirst(new MyCustomChannelInboundHandlerAdapter());
                    }
                })));
    }

But reactor-netty have deprecated method bootstrap since version 0.9.10 by this PR: https://github.com/reactor/reactor-netty/pull/1175.

How can I obtain the same behavior with new API?

Upvotes: 3

Views: 565

Answers (1)

Violeta Georgieva
Violeta Georgieva

Reputation: 2292

This was deprecated because in Reactor Netty 1.0.0 Bootstrap and ServerBootstrap are not used anymore. https://github.com/reactor/reactor-netty/releases/tag/v1.0.0 There is no replacement for this particular use case in 0.9.x. In 1.0.0 the replacement is doOnChannelInit If your build restricts the usage of deprecated APIs, please open a feature request and we will try to back port the API from 1.0.0 version.

Upvotes: 1

Related Questions