From 433bd337f47145066007e4dc779448e7e9a08e97 Mon Sep 17 00:00:00 2001 From: Vedran Pavic Date: Mon, 18 Sep 2023 21:18:40 +0200 Subject: [PATCH] Rename JMS listener minimum concurrency property This commit renames `spring.jms.listener.concurrency` property to `spring.jms.listener.min-concurrency` in order to better align it with `spring.jms.listener.max-concurrency`. See gh-37451 --- .../boot/autoconfigure/jms/JmsProperties.java | 24 ++++++++++++++----- .../jms/JmsAutoConfigurationTests.java | 2 +- .../autoconfigure/jms/JmsPropertiesTests.java | 4 ++-- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/JmsProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/JmsProperties.java index a4fdc85503..7b0cb61d45 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/JmsProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/JmsProperties.java @@ -19,6 +19,7 @@ package org.springframework.boot.autoconfigure.jms; import java.time.Duration; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.DeprecatedConfigurationProperty; /** * Configuration properties for JMS. @@ -148,7 +149,7 @@ public class JmsProperties { /** * Minimum number of concurrent consumers. */ - private Integer concurrency; + private Integer minConcurrency; /** * Maximum number of concurrent consumers. @@ -178,12 +179,23 @@ public class JmsProperties { this.acknowledgeMode = acknowledgeMode; } + @DeprecatedConfigurationProperty(replacement = "spring.jms.listener.min-concurrency", since = "3.2.0") + @Deprecated(since = "3.2.0", forRemoval = true) public Integer getConcurrency() { - return this.concurrency; + return this.minConcurrency; } + @Deprecated(since = "3.2.0", forRemoval = true) public void setConcurrency(Integer concurrency) { - this.concurrency = concurrency; + this.minConcurrency = concurrency; + } + + public Integer getMinConcurrency() { + return this.minConcurrency; + } + + public void setMinConcurrency(Integer minConcurrency) { + this.minConcurrency = minConcurrency; } public Integer getMaxConcurrency() { @@ -195,11 +207,11 @@ public class JmsProperties { } public String formatConcurrency() { - if (this.concurrency == null) { + if (this.minConcurrency == null) { return (this.maxConcurrency != null) ? "1-" + this.maxConcurrency : null; } - return ((this.maxConcurrency != null) ? this.concurrency + "-" + this.maxConcurrency - : String.valueOf(this.concurrency)); + return ((this.maxConcurrency != null) ? this.minConcurrency + "-" + this.maxConcurrency + : String.valueOf(this.minConcurrency)); } public Duration getReceiveTimeout() { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/JmsAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/JmsAutoConfigurationTests.java index 17692a1b7c..e89c071254 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/JmsAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/JmsAutoConfigurationTests.java @@ -143,7 +143,7 @@ class JmsAutoConfigurationTests { void testJmsListenerContainerFactoryWithCustomSettings() { this.contextRunner.withUserConfiguration(EnableJmsConfiguration.class) .withPropertyValues("spring.jms.listener.autoStartup=false", "spring.jms.listener.acknowledgeMode=client", - "spring.jms.listener.concurrency=2", "spring.jms.listener.receiveTimeout=2s", + "spring.jms.listener.minConcurrency=2", "spring.jms.listener.receiveTimeout=2s", "spring.jms.listener.maxConcurrency=10") .run(this::testJmsListenerContainerFactoryWithCustomSettings); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/JmsPropertiesTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/JmsPropertiesTests.java index 7ddbecd5c8..a30c95d604 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/JmsPropertiesTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/JmsPropertiesTests.java @@ -40,7 +40,7 @@ class JmsPropertiesTests { @Test void formatConcurrencyOnlyLowerBound() { JmsProperties properties = new JmsProperties(); - properties.getListener().setConcurrency(2); + properties.getListener().setMinConcurrency(2); assertThat(properties.getListener().formatConcurrency()).isEqualTo("2"); } @@ -54,7 +54,7 @@ class JmsPropertiesTests { @Test void formatConcurrencyBothBounds() { JmsProperties properties = new JmsProperties(); - properties.getListener().setConcurrency(2); + properties.getListener().setMinConcurrency(2); properties.getListener().setMaxConcurrency(10); assertThat(properties.getListener().formatConcurrency()).isEqualTo("2-10"); }