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
pull/37559/head
Vedran Pavic 1 year ago committed by Moritz Halbritter
parent 2015046a69
commit 433bd337f4

@ -19,6 +19,7 @@ package org.springframework.boot.autoconfigure.jms;
import java.time.Duration; import java.time.Duration;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
/** /**
* Configuration properties for JMS. * Configuration properties for JMS.
@ -148,7 +149,7 @@ public class JmsProperties {
/** /**
* Minimum number of concurrent consumers. * Minimum number of concurrent consumers.
*/ */
private Integer concurrency; private Integer minConcurrency;
/** /**
* Maximum number of concurrent consumers. * Maximum number of concurrent consumers.
@ -178,12 +179,23 @@ public class JmsProperties {
this.acknowledgeMode = acknowledgeMode; this.acknowledgeMode = acknowledgeMode;
} }
@DeprecatedConfigurationProperty(replacement = "spring.jms.listener.min-concurrency", since = "3.2.0")
@Deprecated(since = "3.2.0", forRemoval = true)
public Integer getConcurrency() { public Integer getConcurrency() {
return this.concurrency; return this.minConcurrency;
} }
@Deprecated(since = "3.2.0", forRemoval = true)
public void setConcurrency(Integer concurrency) { 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() { public Integer getMaxConcurrency() {
@ -195,11 +207,11 @@ public class JmsProperties {
} }
public String formatConcurrency() { public String formatConcurrency() {
if (this.concurrency == null) { if (this.minConcurrency == null) {
return (this.maxConcurrency != null) ? "1-" + this.maxConcurrency : null; return (this.maxConcurrency != null) ? "1-" + this.maxConcurrency : null;
} }
return ((this.maxConcurrency != null) ? this.concurrency + "-" + this.maxConcurrency return ((this.maxConcurrency != null) ? this.minConcurrency + "-" + this.maxConcurrency
: String.valueOf(this.concurrency)); : String.valueOf(this.minConcurrency));
} }
public Duration getReceiveTimeout() { public Duration getReceiveTimeout() {

@ -143,7 +143,7 @@ class JmsAutoConfigurationTests {
void testJmsListenerContainerFactoryWithCustomSettings() { void testJmsListenerContainerFactoryWithCustomSettings() {
this.contextRunner.withUserConfiguration(EnableJmsConfiguration.class) this.contextRunner.withUserConfiguration(EnableJmsConfiguration.class)
.withPropertyValues("spring.jms.listener.autoStartup=false", "spring.jms.listener.acknowledgeMode=client", .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") "spring.jms.listener.maxConcurrency=10")
.run(this::testJmsListenerContainerFactoryWithCustomSettings); .run(this::testJmsListenerContainerFactoryWithCustomSettings);
} }

@ -40,7 +40,7 @@ class JmsPropertiesTests {
@Test @Test
void formatConcurrencyOnlyLowerBound() { void formatConcurrencyOnlyLowerBound() {
JmsProperties properties = new JmsProperties(); JmsProperties properties = new JmsProperties();
properties.getListener().setConcurrency(2); properties.getListener().setMinConcurrency(2);
assertThat(properties.getListener().formatConcurrency()).isEqualTo("2"); assertThat(properties.getListener().formatConcurrency()).isEqualTo("2");
} }
@ -54,7 +54,7 @@ class JmsPropertiesTests {
@Test @Test
void formatConcurrencyBothBounds() { void formatConcurrencyBothBounds() {
JmsProperties properties = new JmsProperties(); JmsProperties properties = new JmsProperties();
properties.getListener().setConcurrency(2); properties.getListener().setMinConcurrency(2);
properties.getListener().setMaxConcurrency(10); properties.getListener().setMaxConcurrency(10);
assertThat(properties.getListener().formatConcurrency()).isEqualTo("2-10"); assertThat(properties.getListener().formatConcurrency()).isEqualTo("2-10");
} }

Loading…
Cancel
Save