This is an automated email from the ASF dual-hosted git repository.
tabish pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/artemis.git
The following commit(s) were added to refs/heads/main by this push:
new 78f7e7e367 ARTEMIS-5861 use timeout when closing Netty ChannelGroups
78f7e7e367 is described below
commit 78f7e7e367decbec194260f6e19116406f80e835
Author: Justin Bertram <[email protected]>
AuthorDate: Tue Jan 27 12:56:41 2026 -0600
ARTEMIS-5861 use timeout when closing Netty ChannelGroups
---
.../core/remoting/impl/netty/NettyAcceptor.java | 35 ++++++++++------------
.../artemis/core/server/ActiveMQServerLogger.java | 8 ++---
docs/user-manual/configuring-transports.adoc | 6 ++++
3 files changed, 25 insertions(+), 24 deletions(-)
diff --git
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
index e4fb9fd218..1a093ea558 100644
---
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
+++
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
@@ -796,23 +796,8 @@ public class NettyAcceptor extends AbstractAcceptor {
batchFlusherFuture = null;
}
- // serverChannelGroup has been unbound in pause()
- if (serverChannelGroup != null) {
- serverChannelGroup.close().awaitUninterruptibly();
- }
-
- if (channelGroup != null) {
- ChannelGroupFuture future =
channelGroup.close().awaitUninterruptibly();
-
- if (!future.isSuccess()) {
- ActiveMQServerLogger.LOGGER.nettyChannelGroupError();
- for (Channel channel : future.group()) {
- if (channel.isActive()) {
-
ActiveMQServerLogger.LOGGER.nettyChannelStillOpen(channel,
ProxyProtocolUtil.getRemoteAddress(channel));
- }
- }
- }
- }
+ closeChannelGroup(serverChannelGroup);
+ closeChannelGroup(channelGroup);
channelClazz = null;
@@ -835,6 +820,17 @@ public class NettyAcceptor extends AbstractAcceptor {
}
}
+ private void closeChannelGroup(ChannelGroup channelGroup) {
+ if (channelGroup != null &&
!channelGroup.close().awaitUninterruptibly(shutdownTimeout,
TimeUnit.MILLISECONDS)) {
+ ActiveMQServerLogger.LOGGER.nettyChannelGroupError(getName());
+ for (Channel channel : channelGroup) {
+ if (channel.isActive()) {
+ ActiveMQServerLogger.LOGGER.nettyChannelStillOpen(channel,
ProxyProtocolUtil.getRemoteAddress(channel), getName());
+ }
+ }
+ }
+ }
+
@Override
public void notifyStop() {
if (notificationService != null) {
@@ -868,10 +864,9 @@ public class NettyAcceptor extends AbstractAcceptor {
// We *pause* the acceptor so no new connections are made
if (serverChannelGroup != null) {
- ChannelGroupFuture future =
serverChannelGroup.close().awaitUninterruptibly();
- if (!future.isSuccess()) {
+ if (!serverChannelGroup.close().awaitUninterruptibly(shutdownTimeout,
TimeUnit.MILLISECONDS)) {
ActiveMQServerLogger.LOGGER.nettyChannelGroupBindError();
- for (Channel channel : future.group()) {
+ for (Channel channel : serverChannelGroup) {
if (channel.isActive()) {
ActiveMQServerLogger.LOGGER.nettyChannelStillBound(channel,
ProxyProtocolUtil.getRemoteAddress(channel));
}
diff --git
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java
index fa75e685d4..f4ed4d905d 100644
---
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java
+++
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java
@@ -492,11 +492,11 @@ public interface ActiveMQServerLogger {
@LogMessage(id = 222072, value = "Timed out flushing channel on
InVMConnection", level = LogMessage.Level.WARN)
void timedOutFlushingInvmChannel();
- @LogMessage(id = 222074, value = "channel group did not completely close",
level = LogMessage.Level.WARN)
- void nettyChannelGroupError();
+ @LogMessage(id = 222074, value = "Netty ChannelGroup did not completely
close for acceptor '{}'", level = LogMessage.Level.WARN)
+ void nettyChannelGroupError(String acceptor);
- @LogMessage(id = 222075, value = "{} is still connected to {}", level =
LogMessage.Level.WARN)
- void nettyChannelStillOpen(Channel channel, String remoteAddress);
+ @LogMessage(id = 222075, value = "{} is still connected to {} for acceptor
'{}'", level = LogMessage.Level.WARN)
+ void nettyChannelStillOpen(Channel channel, String remoteAddress, String
acceptor);
@LogMessage(id = 222076, value = "channel group did not completely unbind",
level = LogMessage.Level.WARN)
void nettyChannelGroupBindError();
diff --git a/docs/user-manual/configuring-transports.adoc
b/docs/user-manual/configuring-transports.adoc
index 4545d85b83..b2c71d019c 100644
--- a/docs/user-manual/configuring-transports.adoc
+++ b/docs/user-manual/configuring-transports.adoc
@@ -236,6 +236,12 @@ autoStart::
Determines whether or not an acceptor will start automatically when the broker
is started.
Default value is `true`.
+shutdownTimeout::
+This is only valid for acceptors.
+It is the number of milliseconds the broker will wait when shutting down each
of the various Netty `ChannelGroup` instances as well as the `EventLoopGroup`
instance associated with the acceptor.
+The default is `3000`.
+The default can also be set with the Java system property
`DEFAULT_SHUTDOWN_TIMEOUT`.
+
=== Configuring Netty Native Transport
Netty Native Transport support exists for selected OS platforms in order to
use native sockets/io instead of Java NIO.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]