Description
The field clientIP in ClientConfig.class maybe static?
The problem is that how much consumer service has, it is need to register same number of times.
And I alse use windows dev environment, this make me worried。NetworkInterface.getNetworkInterfaces method cost too much time, and it need cost coumser nums multiply method cost times, this make my application start too slow.
So, I think the filed The field clientIP in ClientConfig.class maybe static?Or it has other uses?But I only konw little of it.
Can someone tell me?
ClientConfig.class 中的 clientIP 字段或许应该是static的?
目前我使用windows作为本地的开发环境,NetworkInterface.getNetworkInterfaces方法每获取一次都需要花费不少的时间,而且每有一个consumer,就会在注册的时候调用一次这方法,这将花费consumer数量X单次时间 的巨长的时间,甚至在我启用懒加载的时候超出了服务启动完成的时间。
所以我想ClientConfig.class中的字段是否可能是static的?可能这个字段还有其他的用途?我对它了解太少了。
有人能告诉我吗?
public class ClientConfig { public static final String SEND_MESSAGE_WITH_VIP_CHANNEL_PROPERTY = "com.rocketmq.sendMessageWithVIPChannel"; private String namesrvAddr = NameServerAddressUtils.getNameServerAddresses(); private String clientIP = RemotingUtil.getLocalAddress(); private String instanceName = System.getProperty("rocketmq.client.name", "DEFAULT"); private int clientCallbackExecutorThreads = Runtime.getRuntime().availableProcessors(); protected String namespace; protected AccessChannel accessChannel = AccessChannel.LOCAL;
Activity
odbozhou commentedon Aug 26, 2021
ClientIp is dynamically acquired at startup. Static variables are generally used to save constants determined during compilation. Static variables are not suitable.
Obtaining ip information locally does not go through the network, and generally does not take a long time. You can locate the specific time-consuming time.
WuShang-3306 commentedon Aug 26, 2021
Thanks for your help.
There is 100+ consumes in my one service.All register completed cost more then 40 sconds.If i disable Disable some network adapters like wlan, it will Halve the time spent,but i think it still too slow。
Also,clientIp in all consumes is same(I don't use clusters or anything like that),so I think this field meybe static, only query once when class has been loaded.
Or meybe provide one way when in this environment that can set use NetworkInterface.getNetworkInterfaces method only once?
Thank you.
Git-Yang commentedon Aug 28, 2021
The clientIP will be obtained only when the clientInstance is started for the first time. Do the 100+ consumptions you mentioned use the same clientInstance?
github-actions commentedon Sep 8, 2022
This issue is stale because it has been open for 365 days with no activity. It will be closed in 3 days if no further activity occurs.
github-actions commentedon Sep 12, 2022
This issue was closed because it has been inactive for 3 days since being marked as stale.