Merge pull request #11618 from YevhenBondarenko/feature/http-client-max-connections
Added ability to configure max connections for TbHttpClient
This commit is contained in:
commit
121e41a2e9
@ -42,6 +42,7 @@ import org.thingsboard.server.common.data.StringUtils;
|
|||||||
import org.thingsboard.server.common.msg.TbMsg;
|
import org.thingsboard.server.common.msg.TbMsg;
|
||||||
import org.thingsboard.server.common.msg.TbMsgMetaData;
|
import org.thingsboard.server.common.msg.TbMsgMetaData;
|
||||||
import reactor.netty.http.client.HttpClient;
|
import reactor.netty.http.client.HttpClient;
|
||||||
|
import reactor.netty.resources.ConnectionProvider;
|
||||||
import reactor.netty.transport.ProxyProvider;
|
import reactor.netty.transport.ProxyProvider;
|
||||||
|
|
||||||
import javax.net.ssl.SSLException;
|
import javax.net.ssl.SSLException;
|
||||||
@ -95,7 +96,12 @@ public class TbHttpClient {
|
|||||||
semaphore = new Semaphore(config.getMaxParallelRequestsCount());
|
semaphore = new Semaphore(config.getMaxParallelRequestsCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpClient httpClient = HttpClient.create()
|
ConnectionProvider connectionProvider = ConnectionProvider
|
||||||
|
.builder("rule-engine-http-client")
|
||||||
|
.maxConnections(getPoolMaxConnections())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
HttpClient httpClient = HttpClient.create(connectionProvider)
|
||||||
.runOn(getSharedOrCreateEventLoopGroup(eventLoopGroupShared))
|
.runOn(getSharedOrCreateEventLoopGroup(eventLoopGroupShared))
|
||||||
.doOnConnected(c ->
|
.doOnConnected(c ->
|
||||||
c.addHandlerLast(new ReadTimeoutHandler(config.getReadTimeoutMs(), TimeUnit.MILLISECONDS)));
|
c.addHandlerLast(new ReadTimeoutHandler(config.getReadTimeoutMs(), TimeUnit.MILLISECONDS)));
|
||||||
@ -143,6 +149,18 @@ public class TbHttpClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int getPoolMaxConnections() {
|
||||||
|
String poolMaxConnectionsEnv = System.getenv("TB_RE_HTTP_CLIENT_POOL_MAX_CONNECTIONS");
|
||||||
|
|
||||||
|
int poolMaxConnections;
|
||||||
|
if (poolMaxConnectionsEnv != null) {
|
||||||
|
poolMaxConnections = Integer.parseInt(poolMaxConnectionsEnv);
|
||||||
|
} else {
|
||||||
|
poolMaxConnections = ConnectionProvider.DEFAULT_POOL_MAX_CONNECTIONS;
|
||||||
|
}
|
||||||
|
return poolMaxConnections;
|
||||||
|
}
|
||||||
|
|
||||||
private void validateMaxInMemoryBufferSize(TbRestApiCallNodeConfiguration config) throws TbNodeException {
|
private void validateMaxInMemoryBufferSize(TbRestApiCallNodeConfiguration config) throws TbNodeException {
|
||||||
int systemMaxInMemoryBufferSizeInKb = 25000;
|
int systemMaxInMemoryBufferSizeInKb = 25000;
|
||||||
try {
|
try {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user