Skip to content

Commit 6761c82

Browse files
jbertramtabish121
authored andcommitted
ARTEMIS-5832 clarify docs for client thread pooling
1 parent ed18b53 commit 6761c82

File tree

2 files changed

+59
-8
lines changed

2 files changed

+59
-8
lines changed

artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ private synchronized void setThreadPools() {
219219
flowControlThreadPool = new ActiveMQThreadPoolExecutor(0, config.flowControlThreadPoolMaxSize, 60L, TimeUnit.SECONDS, factory);
220220
}
221221

222-
factory = getThreadFactory("client-factory-pinger-");
222+
factory = getThreadFactory("client-factory-scheduled-");
223223
scheduledThreadPool = Executors.newScheduledThreadPool(config.scheduledThreadPoolMaxSize, factory);
224224
}
225225
this.updateArrayActor = new Actor<>(threadPool, this::internalUpdateArray);

docs/user-manual/thread-pooling.adoc

Lines changed: 58 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,17 +110,68 @@ in-vm connectivity and invoking failure listeners for Netty
110110
`Log4j2-TF-\*-Scheduled-*`::
111111
executes Log4j2 tasks related to `CronTriggeringPolicy` used by default `log4j2.properties`
112112

113-
114113
== Client-Side Thread Management
115114

116-
On the client side, the Core client maintains a single, "global" static scheduled thread pool and a single, "global" static general thread pool for use by all clients using the same classloader in that JVM instance.
115+
On the Core client thread pools exist for each of the following:
117116

118-
The static scheduled thread pool has a maximum size of `5` threads by default.
119-
This can be changed using the `scheduledThreadPoolMaxSize` URI parameter.
117+
* scheduled tasks
118+
* general use
119+
* flow control
120+
* remoting (managed by Netty on a per-connector basis)
120121

121-
The general purpose thread pool has an unbounded maximum size.
122-
This is changed using the `threadPoolMaxSize` URL parameter.
122+
These are used by all clients using the same classloader in a JVM.
123123

124-
If required the Core client can also be configured so that each `ClientSessionFactory` instance does not use these "global" static pools but instead maintains its own scheduled and general purpose pool.
124+
If required each `ClientSessionFactory` instance can be configured so that it does not use these global static pools but instead maintains individual pools.
125125
Any sessions created from that `ClientSessionFactory` will use those pools instead.
126126
This is configured using the `useGlobalPools` boolean URL parameter.
127+
The default is `true`.
128+
129+
=== Scheduled Thread Pool
130+
131+
The scheduled thread pool is used for activities that require running periodically or with delays.
132+
This includes tasks like:
133+
134+
* sending `PING` packets to the broker
135+
* flushing network data to the wire if `batchDelay` > `0`
136+
137+
The maximum number of threads used by this pool can be configured using the `scheduledThreadPoolMaxSize` URI parameter, e.g.:
138+
139+
----
140+
tcp://host:61616?scheduledThreadPoolMaxSize=10
141+
----
142+
143+
The Java system property `activemq.artemis.client.global.scheduled.thread.pool.core.size` can also be used.
144+
145+
The default `scheduledThreadPoolMaxSize` is `5`.
146+
A value of `0` is not allowed.
147+
148+
If using a global pool the name for threads will contain `activemq-client-global-scheduled`.
149+
If using a non-global pool the name for threads will contain `activemq-client-factory-scheduled`.
150+
151+
=== General Purpose Thread Pool
152+
153+
This general purpose thread pool is used for most asynchronous actions.
154+
The maximum number of threads used by this pool is configured using the `threadPoolMaxSize` URI parameter, e.g.:
155+
156+
----
157+
tcp://host:61616?threadPoolMaxSize=10
158+
----
159+
160+
By default, a global pool will be used and the default `threadPoolMaxSize` will be `Runtime.getRuntime().availableProcessors()` * 8.
161+
If using a non-global pool the default `threadPoolMaxSize` is `-1`.
162+
A value of `-1` signifies that the thread pool has _no upper bound_ and new threads will be created on demand if there are not enough threads already available to satisfy demand.
163+
A value of `0` is not allowed.
164+
The minimum valid value is `2`.
165+
166+
Any threads in this pool which are idle for `60` seconds will be terminated.
167+
168+
The name for threads from this pool will contain `activemq-client-factory`.
169+
170+
=== Netty Connectors
171+
172+
Netty threads for processing network traffic, by default, are capped on a per-connector basis at three times the number of cores (or hyper-threads) as reported by `Runtime.getRuntime().availableProcessors()`.
173+
To override this value, you can set the number of threads by specifying the URI parameter `remotingThreads`.
174+
See the xref:configuring-transports.adoc#configuring-the-transport[configuring transports] for more information on this.
175+
176+
Threads names will include the name of their corresponding acceptor with the prefix `activemq-remoting-`.
177+
For example, for the acceptor named `amqp` the corresponding thread names will contain `activemq-remoting-amqp-<brokerName>`.

0 commit comments

Comments
 (0)