Commit 1f875d55 authored by Andy Wilkinson's avatar Andy Wilkinson

Polish "Add a config property for JMS listener container's receive timeout"

See gh-17332
parent 1cde6578
......@@ -156,12 +156,11 @@ public class JmsProperties {
private Integer maxConcurrency;
/**
* Timeout to use for receive calls. By default, the listener uses a 1s timeout on
* its polling loop. See
* @see org.springframework.jms.listener.AbstractPollingMessageListenerContainer#setReceiveTimeout
* for more details on this value and the meaning of special values 0 and -1.
* Timeout to use for receive calls. Use -1 for a no-wait receive or 0 for no
* timeout at all. The latter is only feasible if not running within a transaction
* manager and is generally discouraged since it prevents clean shutdown.
*/
private Duration receiveTimeout;
private Duration receiveTimeout = Duration.ofSeconds(1);
public boolean isAutoStartup() {
return this.autoStartup;
......
......@@ -20,6 +20,8 @@ import java.time.Duration;
import org.junit.jupiter.api.Test;
import org.springframework.jms.listener.AbstractPollingMessageListenerContainer;
import static org.assertj.core.api.Assertions.assertThat;
/**
......@@ -78,4 +80,10 @@ class JmsPropertiesTests {
assertThat(properties.getTemplate().determineQosEnabled()).isTrue();
}
@Test
void defaultReceiveTimeoutMatchesListenerContainersDefault() {
assertThat(new JmsProperties().getListener().getReceiveTimeout())
.isEqualTo(Duration.ofMillis(AbstractPollingMessageListenerContainer.DEFAULT_RECEIVE_TIMEOUT));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment