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
This commit is contained in:
Vedran Pavic 2023-09-01 23:42:01 +02:00 committed by Andy Wilkinson
parent 98bfaf0412
commit 366607f517
2 changed files with 2 additions and 3 deletions

View File

@ -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() {

View File

@ -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