diff --git a/client/src/main/java/org/asynchttpclient/AsyncHttpClientConfig.java b/client/src/main/java/org/asynchttpclient/AsyncHttpClientConfig.java
index 862aa2ce9f..85f35a4936 100644
--- a/client/src/main/java/org/asynchttpclient/AsyncHttpClientConfig.java
+++ b/client/src/main/java/org/asynchttpclient/AsyncHttpClientConfig.java
@@ -51,6 +51,13 @@ public interface AsyncHttpClientConfig {
*/
String getThreadPoolName();
+ /**
+ * Return the name of threadPool for {@link org.asynchttpclient.netty.channel.ChannelManager}, which is used for thread naming and debugging.
+ *
+ * @return the name.
+ */
+ String getChannelThreadPoolName();
+
/**
* Return the maximum number of connections an {@link AsyncHttpClient} can handle.
*
@@ -149,6 +156,14 @@ public interface AsyncHttpClientConfig {
*/
ThreadFactory getThreadFactory();
+ /**
+ * Return the {@link java.util.concurrent.ThreadFactory} an {@link org.asynchttpclient.netty.channel.ChannelManager} use for handling I/O.
+ *
+ * @return the {@link java.util.concurrent.ThreadFactory} an {@link org.asynchttpclient.netty.channel.ChannelManager} use for handling I/O.
+ * If no {@link ThreadFactory} has been explicitly provided, this method will return null
+ */
+ ThreadFactory getChannelThreadFactory();
+
/**
* An instance of {@link ProxyServer} used by an {@link AsyncHttpClient}
*
diff --git a/client/src/main/java/org/asynchttpclient/DefaultAsyncHttpClientConfig.java b/client/src/main/java/org/asynchttpclient/DefaultAsyncHttpClientConfig.java
index d26612fb6d..5f987d8f99 100644
--- a/client/src/main/java/org/asynchttpclient/DefaultAsyncHttpClientConfig.java
+++ b/client/src/main/java/org/asynchttpclient/DefaultAsyncHttpClientConfig.java
@@ -112,6 +112,7 @@ public class DefaultAsyncHttpClientConfig implements AsyncHttpClientConfig {
// internals
private final String threadPoolName;
+ private final String channelThreadPoolName;
private final int httpClientCodecMaxInitialLineLength;
private final int httpClientCodecMaxHeaderSize;
private final int httpClientCodecMaxChunkSize;
@@ -128,6 +129,7 @@ public class DefaultAsyncHttpClientConfig implements AsyncHttpClientConfig {
private final int soRcvBuf;
private final Timer nettyTimer;
private final ThreadFactory threadFactory;
+ private final ThreadFactory channelThreadFactory;
private final Consumer httpAdditionalChannelInitializer;
private final Consumer wsAdditionalChannelInitializer;
private final ResponseBodyPartFactory responseBodyPartFactory;
@@ -199,6 +201,7 @@ private DefaultAsyncHttpClientConfig(// http
// internals
String threadPoolName,
+ String channelThreadPoolName,
int httpClientCodecMaxInitialLineLength,
int httpClientCodecMaxHeaderSize,
int httpClientCodecMaxChunkSize,
@@ -212,6 +215,7 @@ private DefaultAsyncHttpClientConfig(// http
ByteBufAllocator allocator,
Timer nettyTimer,
ThreadFactory threadFactory,
+ ThreadFactory channelThreadFactory,
Consumer httpAdditionalChannelInitializer,
Consumer wsAdditionalChannelInitializer,
ResponseBodyPartFactory responseBodyPartFactory,
@@ -287,6 +291,7 @@ private DefaultAsyncHttpClientConfig(// http
// internals
this.threadPoolName = threadPoolName;
+ this.channelThreadPoolName = channelThreadPoolName;
this.httpClientCodecMaxInitialLineLength = httpClientCodecMaxInitialLineLength;
this.httpClientCodecMaxHeaderSize = httpClientCodecMaxHeaderSize;
this.httpClientCodecMaxChunkSize = httpClientCodecMaxChunkSize;
@@ -298,6 +303,7 @@ private DefaultAsyncHttpClientConfig(// http
this.allocator = allocator;
this.nettyTimer = nettyTimer;
this.threadFactory = threadFactory;
+ this.channelThreadFactory = channelThreadFactory;
this.httpAdditionalChannelInitializer = httpAdditionalChannelInitializer;
this.wsAdditionalChannelInitializer = wsAdditionalChannelInitializer;
this.responseBodyPartFactory = responseBodyPartFactory;
@@ -581,6 +587,11 @@ public String getThreadPoolName() {
return threadPoolName;
}
+ @Override
+ public String getChannelThreadPoolName() {
+ return channelThreadPoolName;
+ }
+
@Override
public int getHttpClientCodecMaxInitialLineLength() {
return httpClientCodecMaxInitialLineLength;
@@ -636,6 +647,11 @@ public ThreadFactory getThreadFactory() {
return threadFactory;
}
+ @Override
+ public ThreadFactory getChannelThreadFactory() {
+ return channelThreadFactory;
+ }
+
@Override
public Consumer getHttpAdditionalChannelInitializer() {
return httpAdditionalChannelInitializer;
@@ -732,6 +748,7 @@ public static class Builder {
// internals
private String threadPoolName = defaultThreadPoolName();
+ private String channelThreadPoolName = defaultChannelThreadPoolName();
private int httpClientCodecMaxInitialLineLength = defaultHttpClientCodecMaxInitialLineLength();
private int httpClientCodecMaxHeaderSize = defaultHttpClientCodecMaxHeaderSize();
private int httpClientCodecMaxChunkSize = defaultHttpClientCodecMaxChunkSize();
@@ -743,6 +760,7 @@ public static class Builder {
private EventLoopGroup eventLoopGroup;
private Timer nettyTimer;
private ThreadFactory threadFactory;
+ private ThreadFactory channelThreadFactory;
private Consumer httpAdditionalChannelInitializer;
private Consumer wsAdditionalChannelInitializer;
private ResponseBodyPartFactory responseBodyPartFactory = ResponseBodyPartFactory.EAGER;
@@ -814,6 +832,7 @@ public Builder(AsyncHttpClientConfig config) {
// internals
threadPoolName = config.getThreadPoolName();
+ channelThreadPoolName = config.getChannelThreadPoolName();
httpClientCodecMaxInitialLineLength = config.getHttpClientCodecMaxInitialLineLength();
httpClientCodecMaxHeaderSize = config.getHttpClientCodecMaxHeaderSize();
httpClientCodecMaxChunkSize = config.getHttpClientCodecMaxChunkSize();
@@ -824,6 +843,7 @@ public Builder(AsyncHttpClientConfig config) {
allocator = config.getAllocator();
nettyTimer = config.getNettyTimer();
threadFactory = config.getThreadFactory();
+ channelThreadFactory = config.getChannelThreadFactory();
httpAdditionalChannelInitializer = config.getHttpAdditionalChannelInitializer();
wsAdditionalChannelInitializer = config.getWsAdditionalChannelInitializer();
responseBodyPartFactory = config.getResponseBodyPartFactory();
@@ -1148,6 +1168,11 @@ public Builder setThreadPoolName(String threadPoolName) {
return this;
}
+ public Builder setChannelThreadPoolName(String channelThreadPoolName) {
+ this.channelThreadPoolName = channelThreadPoolName;
+ return this;
+ }
+
public Builder setHttpClientCodecMaxInitialLineLength(int httpClientCodecMaxInitialLineLength) {
this.httpClientCodecMaxInitialLineLength = httpClientCodecMaxInitialLineLength;
return this;
@@ -1204,6 +1229,11 @@ public Builder setThreadFactory(ThreadFactory threadFactory) {
return this;
}
+ public Builder setChannelThreadFactory(ThreadFactory channelThreadFactory) {
+ this.channelThreadFactory = channelThreadFactory;
+ return this;
+ }
+
public Builder setHttpAdditionalChannelInitializer(Consumer httpAdditionalChannelInitializer) {
this.httpAdditionalChannelInitializer = httpAdditionalChannelInitializer;
return this;
@@ -1291,6 +1321,7 @@ public DefaultAsyncHttpClientConfig build() {
soSndBuf,
soRcvBuf,
threadPoolName,
+ channelThreadPoolName,
httpClientCodecMaxInitialLineLength,
httpClientCodecMaxHeaderSize,
httpClientCodecMaxChunkSize,
@@ -1304,6 +1335,7 @@ public DefaultAsyncHttpClientConfig build() {
allocator,
nettyTimer,
threadFactory,
+ channelThreadFactory,
httpAdditionalChannelInitializer,
wsAdditionalChannelInitializer,
responseBodyPartFactory,
diff --git a/client/src/main/java/org/asynchttpclient/config/AsyncHttpClientConfigDefaults.java b/client/src/main/java/org/asynchttpclient/config/AsyncHttpClientConfigDefaults.java
index fa073bc82f..795d3dfe9e 100644
--- a/client/src/main/java/org/asynchttpclient/config/AsyncHttpClientConfigDefaults.java
+++ b/client/src/main/java/org/asynchttpclient/config/AsyncHttpClientConfigDefaults.java
@@ -20,6 +20,7 @@ public final class AsyncHttpClientConfigDefaults {
public static final String ASYNC_CLIENT_CONFIG_ROOT = "org.asynchttpclient.";
public static final String THREAD_POOL_NAME_CONFIG = "threadPoolName";
+ public static final String CHANNEL_THREAD_POOL_NAME_CONFIG = "channelThreadPoolName";
public static final String MAX_CONNECTIONS_CONFIG = "maxConnections";
public static final String MAX_CONNECTIONS_PER_HOST_CONFIG = "maxConnectionsPerHost";
public static final String ACQUIRE_FREE_CHANNEL_TIMEOUT = "acquireFreeChannelTimeout";
@@ -90,6 +91,10 @@ public static String defaultThreadPoolName() {
return AsyncHttpClientConfigHelper.getAsyncHttpClientConfig().getString(ASYNC_CLIENT_CONFIG_ROOT + THREAD_POOL_NAME_CONFIG);
}
+ public static String defaultChannelThreadPoolName() {
+ return AsyncHttpClientConfigHelper.getAsyncHttpClientConfig().getString(ASYNC_CLIENT_CONFIG_ROOT + CHANNEL_THREAD_POOL_NAME_CONFIG);
+ }
+
public static int defaultMaxConnections() {
return AsyncHttpClientConfigHelper.getAsyncHttpClientConfig().getInt(ASYNC_CLIENT_CONFIG_ROOT + MAX_CONNECTIONS_CONFIG);
}
diff --git a/client/src/main/java/org/asynchttpclient/netty/channel/ChannelManager.java b/client/src/main/java/org/asynchttpclient/netty/channel/ChannelManager.java
index 4488bb6514..d41ee4c1b7 100755
--- a/client/src/main/java/org/asynchttpclient/netty/channel/ChannelManager.java
+++ b/client/src/main/java/org/asynchttpclient/netty/channel/ChannelManager.java
@@ -119,7 +119,7 @@ public ChannelManager(final AsyncHttpClientConfig config, Timer nettyTimer) {
handshakeTimeout = config.getHandshakeTimeout();
// check if external EventLoopGroup is defined
- ThreadFactory threadFactory = config.getThreadFactory() != null ? config.getThreadFactory() : new DefaultThreadFactory(config.getThreadPoolName());
+ ThreadFactory threadFactory = config.getChannelThreadFactory() != null ? config.getChannelThreadFactory() : new DefaultThreadFactory(config.getChannelThreadPoolName());
allowReleaseEventLoopGroup = config.getEventLoopGroup() == null;
TransportFactory extends Channel, ? extends EventLoopGroup> transportFactory;
if (allowReleaseEventLoopGroup) {
diff --git a/client/src/main/resources/org/asynchttpclient/config/ahc-default.properties b/client/src/main/resources/org/asynchttpclient/config/ahc-default.properties
index c6fb355d75..cb876a2cbc 100644
--- a/client/src/main/resources/org/asynchttpclient/config/ahc-default.properties
+++ b/client/src/main/resources/org/asynchttpclient/config/ahc-default.properties
@@ -1,4 +1,5 @@
org.asynchttpclient.threadPoolName=AsyncHttpClient
+org.asynchttpclient.channelThreadPoolName=AHC-Channel
org.asynchttpclient.maxConnections=-1
org.asynchttpclient.maxConnectionsPerHost=-1
org.asynchttpclient.acquireFreeChannelTimeout=0
diff --git a/extras/typesafeconfig/src/main/java/org/asynchttpclient/extras/typesafeconfig/AsyncHttpClientTypesafeConfig.java b/extras/typesafeconfig/src/main/java/org/asynchttpclient/extras/typesafeconfig/AsyncHttpClientTypesafeConfig.java
index 55c88ab251..9a00a842b8 100644
--- a/extras/typesafeconfig/src/main/java/org/asynchttpclient/extras/typesafeconfig/AsyncHttpClientTypesafeConfig.java
+++ b/extras/typesafeconfig/src/main/java/org/asynchttpclient/extras/typesafeconfig/AsyncHttpClientTypesafeConfig.java
@@ -59,6 +59,11 @@ public String getThreadPoolName() {
return getStringOpt(THREAD_POOL_NAME_CONFIG).orElse(defaultThreadPoolName());
}
+ @Override
+ public String getChannelThreadPoolName() {
+ return getStringOpt(CHANNEL_THREAD_POOL_NAME_CONFIG).orElse(defaultChannelThreadPoolName());
+ }
+
@Override
public int getMaxConnections() {
return getIntegerOpt(MAX_CONNECTIONS_CONFIG).orElse(defaultMaxConnections());
@@ -129,6 +134,11 @@ public ThreadFactory getThreadFactory() {
return null;
}
+ @Override
+ public ThreadFactory getChannelThreadFactory() {
+ return null;
+ }
+
@Override
public ProxyServerSelector getProxyServerSelector() {
return ProxyServerSelector.NO_PROXY_SELECTOR;
diff --git a/extras/typesafeconfig/src/test/java/org/asynchttpclient/extras/typesafeconfig/AsyncHttpClientTypesafeConfigTest.java b/extras/typesafeconfig/src/test/java/org/asynchttpclient/extras/typesafeconfig/AsyncHttpClientTypesafeConfigTest.java
index 1decc77490..e2270619dd 100644
--- a/extras/typesafeconfig/src/test/java/org/asynchttpclient/extras/typesafeconfig/AsyncHttpClientTypesafeConfigTest.java
+++ b/extras/typesafeconfig/src/test/java/org/asynchttpclient/extras/typesafeconfig/AsyncHttpClientTypesafeConfigTest.java
@@ -29,6 +29,10 @@ public void testThreadPoolName() {
test(AsyncHttpClientTypesafeConfig::getThreadPoolName, "threadPoolName", "MyHttpClient", "AsyncHttpClient");
}
+ public void testChannelThreadPoolName() {
+ test(AsyncHttpClientTypesafeConfig::getChannelThreadPoolName, "channelThreadPoolName", "MyHttpClient", "AHC-Channel");
+ }
+
public void testMaxTotalConnections() {
test(AsyncHttpClientTypesafeConfig::getMaxConnections, "maxConnections", 100, -1);
}