0

I moved to Spring 2.3.1.RELEASE to 2.4.5.

HttpServer tcpConfiguration Deprecated with new version. How can i configure NioEventLoopGroup with Spring boot 2.4.5.

    public NettyReactiveWebServerFactory factory(NioEventLoopGroup eventLoopGroup) {
        NettyReactiveWebServerFactory factory = new NettyReactiveWebServerFactory();
        factory.setServerCustomizers(Collections.singletonList(new NettyServerCustomizer() {
            @Override
            public HttpServer apply(HttpServer httpServer) {
                return httpServer.tcpConfiguration(tcpServer ->
                        tcpServer.bootstrap(serverBootstrap -> serverBootstrap.group(eventLoopGroup)
                                .channel(NioServerSocketChannel.class)));
            }
        }));
        return factory;
    }

1 Answer 1

2

You should use directly the HttpServer#runOn API. The snippet above should be looking like this:

public NettyReactiveWebServerFactory factory(NioEventLoopGroup eventLoopGroup) {
    NettyReactiveWebServerFactory factory = new NettyReactiveWebServerFactory();
    factory.setServerCustomizers(Collections.singletonList(new NettyServerCustomizer() {
        @Override
        public HttpServer apply(HttpServer httpServer) {
            return httpServer.runOn(eventLoopGroup);
        }
    }));
    return factory;
}
Sign up to request clarification or add additional context in comments.

2 Comments

Do you know how to access the server bootstrap ?
In the recent versions Reactor Netty DOES NOT use ServerBootstrap anymore. Everything that you can add as a configuration via ServerBootstrap, you can add using Reactor Netty API.

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.