> > @wangruyu1 `<dubbo:reference 
> > connections="100">`在远程引用的时候就会创建完成,然后请求会轮询这100个连接,代码在DubboInvoker.doInvoke
> > > 所以我想问能不能配置100个并发在请求时循环使用新的长连接
> > 
> > 
> > 不是很懂你这句话,你的意思是继续创建新连接吗
> 
> 我的意思是100个并发同时第一次请求时,是不是都是用的这100个长连接(因为出现长连接复用会小于100个)?当101次请求来时才会出现长连接复用。因为我从现在测试判断出100个并发并没有都被用到了,应该是出现了长连接复用。
> 我现在想实现每个请求都是优先使用100个长连接中没被用到,如果100个都被用到了,那就循环的复用。相当于,for(i=0;i<100;i++) 
> con=cons[i %100]这样获取长连接。
> 这能不能配置还是只能改源码?

目前消费端源码就是这样实现的;
DubboInvoker
```java
 @Override
    protected Result doInvoke(final Invocation invocation) throws Throwable {
        RpcInvocation inv = (RpcInvocation) invocation;
        final String methodName = RpcUtils.getMethodName(invocation);
        inv.setAttachment(Constants.PATH_KEY, getUrl().getPath());
        inv.setAttachment(Constants.VERSION_KEY, version);

        ExchangeClient currentClient;
        if (clients.length == 1) {
            currentClient = clients[0];
        } else {
            currentClient = clients[index.getAndIncrement() % clients.length];
        }
       ...
```
`currentClient = clients[index.getAndIncrement() % clients.length];`已经实现了你所说的复用。

[ Full content available at: 
https://github.com/apache/incubator-dubbo/issues/3145 ]
This message was relayed via gitbox.apache.org for 
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to