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
2.7.x
Vedran Pavic 1 year ago committed by Andy Wilkinson
parent 98bfaf0412
commit 366607f517

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

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

Loading…
Cancel
Save