diff --git a/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/connection/AbstractConnectionFactory.java b/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/connection/AbstractConnectionFactory.java index 33cb11dcc..fc3e6a093 100644 --- a/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/connection/AbstractConnectionFactory.java +++ b/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/connection/AbstractConnectionFactory.java @@ -478,8 +478,9 @@ protected ExecutorService getExecutorService() { } /** - * How long to wait (milliseconds) for a response to a connection close operation from the broker; default 30000 (30 - * seconds). + * How long to wait (milliseconds) for a response to a connection close operation from the broker; + * default 30000 (30 seconds). + * Also used for {@link com.rabbitmq.client.Channel#waitForConfirms()}. * @param closeTimeout the closeTimeout to set. */ public void setCloseTimeout(int closeTimeout) { diff --git a/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/connection/CachingConnectionFactory.java b/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/connection/CachingConnectionFactory.java index f14aa989b..0aade4832 100644 --- a/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/connection/CachingConnectionFactory.java +++ b/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/connection/CachingConnectionFactory.java @@ -1087,8 +1087,6 @@ public String toString() { private final class CachedChannelInvocationHandler implements InvocationHandler { - private static final int ASYNC_CLOSE_TIMEOUT = 5_000; - private final ChannelCachingConnectionProxy theConnection; private final Deque channelList; @@ -1302,7 +1300,7 @@ private void returnToCache(ChannelProxy proxy) { getChannelsExecutor() .execute(() -> { try { - publisherCallbackChannel.waitForConfirms(ASYNC_CLOSE_TIMEOUT); + publisherCallbackChannel.waitForConfirms(getCloseTimeout()); } catch (InterruptedException ex) { Thread.currentThread().interrupt(); @@ -1426,10 +1424,10 @@ private void asyncClose() { executorService.execute(() -> { try { if (ConfirmType.CORRELATED.equals(CachingConnectionFactory.this.confirmType)) { - channel.waitForConfirmsOrDie(ASYNC_CLOSE_TIMEOUT); + channel.waitForConfirmsOrDie(getCloseTimeout()); } else { - Thread.sleep(ASYNC_CLOSE_TIMEOUT); + Thread.sleep(5_000); // NOSONAR - some time to give the channel a chance to ack } } catch (@SuppressWarnings(UNUSED) InterruptedException e1) {