Browse Source

Make sure endpoint settings override default factory settings

Issue: SPR-16338
pull/1642/merge
Stephane Nicoll 7 years ago
parent
commit
42dfa40151
  1. 4
      spring-jms/src/main/java/org/springframework/jms/config/AbstractJmsListenerContainerFactory.java
  2. 17
      spring-jms/src/test/java/org/springframework/jms/config/JmsListenerContainerFactoryTests.java

4
spring-jms/src/main/java/org/springframework/jms/config/AbstractJmsListenerContainerFactory.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -228,8 +228,8 @@ public abstract class AbstractJmsListenerContainerFactory<C extends AbstractMess @@ -228,8 +228,8 @@ public abstract class AbstractJmsListenerContainerFactory<C extends AbstractMess
instance.setAutoStartup(this.autoStartup);
}
endpoint.setupListenerContainer(instance);
initializeContainer(instance);
endpoint.setupListenerContainer(instance);
return instance;
}

17
spring-jms/src/test/java/org/springframework/jms/config/JmsListenerContainerFactoryTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -150,6 +150,21 @@ public class JmsListenerContainerFactoryTests { @@ -150,6 +150,21 @@ public class JmsListenerContainerFactoryTests {
assertSame(backOff, new DirectFieldAccessor(container).getPropertyValue("backOff"));
}
@Test
public void endpointConcurrencyTakesPrecedence() {
DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
factory.setConcurrency("2-10");
SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
MessageListener messageListener = new MessageListenerAdapter();
endpoint.setMessageListener(messageListener);
endpoint.setDestination("myQueue");
endpoint.setConcurrency("4-6");
DefaultMessageListenerContainer container = factory.createListenerContainer(endpoint);
assertEquals(4, container.getConcurrentConsumers());
assertEquals(6, container.getMaxConcurrentConsumers());
}
private void setDefaultJmsConfig(AbstractJmsListenerContainerFactory<?> factory) {
factory.setConnectionFactory(this.connectionFactory);

Loading…
Cancel
Save