From 366607f51783866aeb6a9115ad5587bfee3997c9 Mon Sep 17 00:00:00 2001 From: Vedran Pavic Date: Fri, 1 Sep 2023 23:42:01 +0200 Subject: [PATCH] Fix handling of JMS listener concurrency properties Update JMS listener concurrency configuration to set the same minimum and maximum number of consumers when users specify only the minimum using `spring.jms.listener.concurrency` property. Prior to this commit, when using `spring.jms.listener.concurrency` to set the minimum number of consumers without also specifying `spring.jms.listener.max-concurrency` would result in effective concurrency where the actual minimum number of consumers is always 1, while the maximum number of consumers is the value of `spring.jms.listener.concurrency`. See gh-37180 --- .../springframework/boot/autoconfigure/jms/JmsProperties.java | 3 +-- .../boot/autoconfigure/jms/JmsPropertiesTests.java | 2 +- 2 files changed, 2 insertions(+), 3 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 337ee8c9ef..8774b27b3a 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 @@ -198,8 +198,7 @@ public class JmsProperties { if (this.concurrency == null) { return (this.maxConcurrency != null) ? "1-" + this.maxConcurrency : null; } - return ((this.maxConcurrency != null) ? this.concurrency + "-" + this.maxConcurrency - : String.valueOf(this.concurrency)); + return this.concurrency + "-" + ((this.maxConcurrency != null) ? this.maxConcurrency : this.concurrency); } public Duration getReceiveTimeout() { 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..8e42211c06 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 @@ -41,7 +41,7 @@ class JmsPropertiesTests { void formatConcurrencyOnlyLowerBound() { JmsProperties properties = new JmsProperties(); properties.getListener().setConcurrency(2); - assertThat(properties.getListener().formatConcurrency()).isEqualTo("2"); + assertThat(properties.getListener().formatConcurrency()).isEqualTo("2-2"); } @Test