在单个应用程序上下文中使用netty的tomcat

qlfbtfca  于 2021-07-16  发布在  Java
关注(0)|答案(0)|浏览(320)

我有一个使用tomcat的spring应用程序,我想将netty作为并行web服务器运行,并在两者之间共享应用程序上下文,我将web flux starter与web连接在一起,但只有tomcat在属性中指定的端口上启动。`@configuration class nettyconfiguration{

@Bean
fun nettyReactiveWebServerFactory(): NettyReactiveWebServerFactory {
    val webServerFactory = NettyReactiveWebServerFactory()
    webServerFactory.addServerCustomizers(EventLoopNettyCustomizer())
    return webServerFactory
}

private class EventLoopNettyCustomizer : NettyServerCustomizer {
    override fun apply(httpServer: HttpServer): HttpServer {
        val parentGroup: EventLoopGroup = NioEventLoopGroup()
        val childGroup: EventLoopGroup = NioEventLoopGroup()
        return httpServer.port(8084)
            .tcpConfiguration { tcpServer ->
                tcpServer
                    .bootstrap { serverBootstrap ->
                        serverBootstrap
                            .group(parentGroup, childGroup)
                            .channel(NioServerSocketChannel::class.java)
                    }
            }
    }
}

}`

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题