简体   繁体   English

Netty 客户端引导程序

[英]Netty client bootstrap

I am developing an application where I have a set of external TCP servers, which I have to connect from within my application.我正在开发一个应用程序,其中有一组外部 TCP 服务器,我必须从我的应用程序中连接它们。

  • I have a set of drivers which connect these servers.我有一组连接这些服务器的驱动程序。
  • a tcp client creating and returning the connection.一个 tcp 客户端创建并返回连接。
  • every driver communicates with an device, which is the tcp server每个驱动程序都与一个设备通信,即 tcp 服务器

Now it is not clear to me what is the correct way to handle the client bootstrap.现在我不清楚处理客户端引导程序的正确方法是什么。 Should the TcpClient create a bootstrap and reuse it to open new channel or is it better to create a new Bootstrap every time a driver connects the device (server)? TcpClient 应该创建一个引导程序并重用它来打开新通道,还是每次驱动程序连接设备(服务器)时创建一个新的引导程序更好?

Usually you would create a new Bootstrap per client (driver) and re-use it.通常您会为每个客户端(驱动程序)创建一个新的Bootstrap程序并重新使用它。 The most important part in general is that you want to re-use the EventLoopGroup if possible.一般来说,最重要的部分是您希望尽可能重用EventLoopGroup You may even share the same group with all the drivers if possible.如果可能,您甚至可以与所有驱动程序共享同一个组。 This will ensure you can maximise the usage of the threads per EventLoopGroup and keep resource usage to a minimum.这将确保您可以最大限度地使用每个EventLoopGroup的线程并将资源使用量保持在最低限度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM