Skip to content

Commit 0747cd6

Browse files
committed
Make sure endpoint settings override default factory settings
Issue: SPR-16338
1 parent 0a30b71 commit 0747cd6

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -200,8 +200,8 @@ public C createListenerContainer(JmsListenerEndpoint endpoint) {
200200
instance.setAutoStartup(this.autoStartup);
201201
}
202202

203-
endpoint.setupListenerContainer(instance);
204203
initializeContainer(instance);
204+
endpoint.setupListenerContainer(instance);
205205

206206
return instance;
207207
}

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

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -149,6 +149,21 @@ public void backOffOverridesRecoveryInterval() {
149149
assertSame(backOff, new DirectFieldAccessor(container).getPropertyValue("backOff"));
150150
}
151151

152+
@Test
153+
public void endpointConcurrencyTakesPrecedence() {
154+
DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
155+
factory.setConcurrency("2-10");
156+
157+
SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
158+
MessageListener messageListener = new MessageListenerAdapter();
159+
endpoint.setMessageListener(messageListener);
160+
endpoint.setDestination("myQueue");
161+
endpoint.setConcurrency("4-6");
162+
DefaultMessageListenerContainer container = factory.createListenerContainer(endpoint);
163+
assertEquals(4, container.getConcurrentConsumers());
164+
assertEquals(6, container.getMaxConcurrentConsumers());
165+
}
166+
152167

153168
private void setDefaultJmsConfig(AbstractJmsListenerContainerFactory<?> factory) {
154169
factory.setConnectionFactory(connectionFactory);

0 commit comments

Comments
 (0)