Add clientId and subscriptionDurable to JmsProperties
See gh-38817
This commit is contained in:
committed by
Moritz Halbritter
parent
06b41bdd2d
commit
3928fac5ba
@@ -36,6 +36,7 @@ import org.springframework.util.Assert;
|
||||
* @author Stephane Nicoll
|
||||
* @author Eddú Meléndez
|
||||
* @author Vedran Pavic
|
||||
* @author Lasse Wulff
|
||||
* @since 1.3.3
|
||||
*/
|
||||
public final class DefaultJmsListenerContainerFactoryConfigurer {
|
||||
@@ -116,6 +117,8 @@ public final class DefaultJmsListenerContainerFactoryConfigurer {
|
||||
Assert.notNull(connectionFactory, "ConnectionFactory must not be null");
|
||||
factory.setConnectionFactory(connectionFactory);
|
||||
factory.setPubSubDomain(this.jmsProperties.isPubSubDomain());
|
||||
factory.setSubscriptionDurable(this.jmsProperties.isSubscriptionDurable());
|
||||
factory.setClientId(this.jmsProperties.getClientId());
|
||||
JmsProperties.Listener listenerProperties = this.jmsProperties.getListener();
|
||||
Session sessionProperties = listenerProperties.getSession();
|
||||
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.springframework.boot.context.properties.DeprecatedConfigurationProper
|
||||
* @author Greg Turnquist
|
||||
* @author Phillip Webb
|
||||
* @author Stephane Nicoll
|
||||
* @author Lasse Wulff
|
||||
* @author Vedran Pavic
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@@ -44,6 +45,16 @@ public class JmsProperties {
|
||||
*/
|
||||
private String jndiName;
|
||||
|
||||
/**
|
||||
* Whether the subscription is durable.
|
||||
*/
|
||||
private boolean subscriptionDurable = false;
|
||||
|
||||
/**
|
||||
* Client id of the connection.
|
||||
*/
|
||||
private String clientId;
|
||||
|
||||
private final Cache cache = new Cache();
|
||||
|
||||
private final Listener listener = new Listener();
|
||||
@@ -58,6 +69,22 @@ public class JmsProperties {
|
||||
this.pubSubDomain = pubSubDomain;
|
||||
}
|
||||
|
||||
public boolean isSubscriptionDurable() {
|
||||
return this.subscriptionDurable;
|
||||
}
|
||||
|
||||
public void setSubscriptionDurable(boolean subscriptionDurable) {
|
||||
this.subscriptionDurable = subscriptionDurable;
|
||||
}
|
||||
|
||||
public String getClientId() {
|
||||
return this.clientId;
|
||||
}
|
||||
|
||||
public void setClientId(String clientId) {
|
||||
this.clientId = clientId;
|
||||
}
|
||||
|
||||
public String getJndiName() {
|
||||
return this.jndiName;
|
||||
}
|
||||
|
||||
@@ -63,6 +63,7 @@ import static org.mockito.Mockito.mock;
|
||||
* @author Aurélien Leboulanger
|
||||
* @author Eddú Meléndez
|
||||
* @author Vedran Pavic
|
||||
* @author Lasse Wulff
|
||||
*/
|
||||
class JmsAutoConfigurationTests {
|
||||
|
||||
@@ -151,7 +152,8 @@ class JmsAutoConfigurationTests {
|
||||
.withPropertyValues("spring.jms.listener.autoStartup=false",
|
||||
"spring.jms.listener.session.acknowledgeMode=client",
|
||||
"spring.jms.listener.session.transacted=false", "spring.jms.listener.minConcurrency=2",
|
||||
"spring.jms.listener.receiveTimeout=2s", "spring.jms.listener.maxConcurrency=10")
|
||||
"spring.jms.listener.receiveTimeout=2s", "spring.jms.listener.maxConcurrency=10",
|
||||
"spring.jms.subscription-durable=true", "spring.jms.client-id=exampleId")
|
||||
.run(this::testJmsListenerContainerFactoryWithCustomSettings);
|
||||
}
|
||||
|
||||
@@ -163,6 +165,8 @@ class JmsAutoConfigurationTests {
|
||||
assertThat(container.getConcurrentConsumers()).isEqualTo(2);
|
||||
assertThat(container.getMaxConcurrentConsumers()).isEqualTo(10);
|
||||
assertThat(container).hasFieldOrPropertyWithValue("receiveTimeout", 2000L);
|
||||
assertThat(container.isSubscriptionDurable()).isTrue();
|
||||
assertThat(container.getClientId()).isEqualTo("exampleId");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user