Rename spring.jms.listener.acknowledge-mode

Closes gh-37602
pull/37607/head
Andy Wilkinson 1 year ago
parent 145fb161a1
commit b7facec4a1

@ -118,9 +118,7 @@ public final class DefaultJmsListenerContainerFactoryConfigurer {
}
JmsProperties.Listener listener = this.jmsProperties.getListener();
factory.setAutoStartup(listener.isAutoStartup());
if (listener.getAcknowledgeMode() != null) {
factory.setSessionAcknowledgeMode(listener.getAcknowledgeMode().getMode());
}
factory.setSessionAcknowledgeMode(listener.getSession().getAcknowledgeMode().getMode());
String concurrency = listener.formatConcurrency();
if (concurrency != null) {
factory.setConcurrency(concurrency);

@ -141,12 +141,6 @@ public class JmsProperties {
*/
private boolean autoStartup = true;
/**
* Acknowledge mode of the container. By default, the listener is transacted with
* automatic acknowledgment.
*/
private AcknowledgeMode acknowledgeMode;
/**
* Minimum number of concurrent consumers. When max-concurrency is not specified
* the minimum will also be used as the maximum.
@ -165,6 +159,8 @@ public class JmsProperties {
*/
private Duration receiveTimeout = Duration.ofSeconds(1);
private final Session session = new Session();
public boolean isAutoStartup() {
return this.autoStartup;
}
@ -173,12 +169,15 @@ public class JmsProperties {
this.autoStartup = autoStartup;
}
@Deprecated(since = "3.2.0", forRemoval = true)
@DeprecatedConfigurationProperty(replacement = "spring.jms.listener.session.acknowledge-mode", since = "3.2.0")
public AcknowledgeMode getAcknowledgeMode() {
return this.acknowledgeMode;
return this.session.getAcknowledgeMode();
}
@Deprecated(since = "3.2.0", forRemoval = true)
public void setAcknowledgeMode(AcknowledgeMode acknowledgeMode) {
this.acknowledgeMode = acknowledgeMode;
this.session.setAcknowledgeMode(acknowledgeMode);
}
@DeprecatedConfigurationProperty(replacement = "spring.jms.listener.min-concurrency", since = "3.2.0")
@ -224,6 +223,27 @@ public class JmsProperties {
this.receiveTimeout = receiveTimeout;
}
public Session getSession() {
return this.session;
}
public static class Session {
/**
* Acknowledge mode of the listener container.
*/
private AcknowledgeMode acknowledgeMode = AcknowledgeMode.AUTO;
public AcknowledgeMode getAcknowledgeMode() {
return this.acknowledgeMode;
}
public void setAcknowledgeMode(AcknowledgeMode acknowledgeMode) {
this.acknowledgeMode = acknowledgeMode;
}
}
}
public static class Template {

@ -1571,6 +1571,10 @@
"name": "spring.jersey.type",
"defaultValue": "servlet"
},
{
"name": "spring.jms.listener.session.acknowledge-mode",
"defaultValue": "auto"
},
{
"name": "spring.jms.template.session.acknowledge-mode",
"defaultValue": "auto"

@ -142,9 +142,9 @@ class JmsAutoConfigurationTests {
@Test
void testJmsListenerContainerFactoryWithCustomSettings() {
this.contextRunner.withUserConfiguration(EnableJmsConfiguration.class)
.withPropertyValues("spring.jms.listener.autoStartup=false", "spring.jms.listener.acknowledgeMode=client",
"spring.jms.listener.minConcurrency=2", "spring.jms.listener.receiveTimeout=2s",
"spring.jms.listener.maxConcurrency=10")
.withPropertyValues("spring.jms.listener.autoStartup=false",
"spring.jms.listener.session.acknowledgeMode=client", "spring.jms.listener.minConcurrency=2",
"spring.jms.listener.receiveTimeout=2s", "spring.jms.listener.maxConcurrency=10")
.run(this::testJmsListenerContainerFactoryWithCustomSettings);
}

Loading…
Cancel
Save