Skip to content

Commit 1f875d5

Browse files
committed
Polish "Add a config property for JMS listener container's receive timeout"
See gh-17332
1 parent 1cde657 commit 1f875d5

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/JmsProperties.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,11 @@ public static class Listener {
156156
private Integer maxConcurrency;
157157

158158
/**
159-
* Timeout to use for receive calls. By default, the listener uses a 1s timeout on
160-
* its polling loop. See
161-
* @see org.springframework.jms.listener.AbstractPollingMessageListenerContainer#setReceiveTimeout
162-
* for more details on this value and the meaning of special values 0 and -1.
159+
* Timeout to use for receive calls. Use -1 for a no-wait receive or 0 for no
160+
* timeout at all. The latter is only feasible if not running within a transaction
161+
* manager and is generally discouraged since it prevents clean shutdown.
163162
*/
164-
private Duration receiveTimeout;
163+
private Duration receiveTimeout = Duration.ofSeconds(1);
165164

166165
public boolean isAutoStartup() {
167166
return this.autoStartup;

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/JmsPropertiesTests.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
import org.junit.jupiter.api.Test;
2222

23+
import org.springframework.jms.listener.AbstractPollingMessageListenerContainer;
24+
2325
import static org.assertj.core.api.Assertions.assertThat;
2426

2527
/**
@@ -78,4 +80,10 @@ void setTimeToLiveEnablesQoS() {
7880
assertThat(properties.getTemplate().determineQosEnabled()).isTrue();
7981
}
8082

83+
@Test
84+
void defaultReceiveTimeoutMatchesListenerContainersDefault() {
85+
assertThat(new JmsProperties().getListener().getReceiveTimeout())
86+
.isEqualTo(Duration.ofMillis(AbstractPollingMessageListenerContainer.DEFAULT_RECEIVE_TIMEOUT));
87+
}
88+
8189
}

0 commit comments

Comments
 (0)