Commit c74e56d1 authored by Maciej Walkowiak's avatar Maciej Walkowiak Committed by Stephane Nicoll

Apply pubSubDomain property to ContainerFactory

Previously, tuning the pubSubDomain flag only impacted the created
JmsTemplate leaving any default listeners with the default settings.

If no default JmsListenerContainerFactory is defined, the created
one is using that property as well now.
parent 4ce62195
......@@ -48,12 +48,16 @@ class JmsAnnotationDrivenConfiguration {
@Autowired(required = false)
private PlatformTransactionManager transactionManager;
@Autowired
private JmsProperties properties;
@Bean
@ConditionalOnMissingBean(name = "jmsListenerContainerFactory")
public DefaultJmsListenerContainerFactory jmsListenerContainerFactory(
ConnectionFactory connectionFactory) {
DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
factory.setConnectionFactory(connectionFactory);
factory.setPubSubDomain(properties.isPubSubDomain());
if (this.transactionManager != null) {
factory.setTransactionManager(this.transactionManager);
}
......
......@@ -34,13 +34,16 @@ import org.springframework.jms.config.DefaultJmsListenerContainerFactory;
import org.springframework.jms.config.JmsListenerConfigUtils;
import org.springframework.jms.config.JmsListenerContainerFactory;
import org.springframework.jms.config.SimpleJmsListenerContainerFactory;
import org.springframework.jms.config.JmsListenerEndpoint;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.listener.DefaultMessageListenerContainer;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
/**
* Tests for {@link JmsAutoConfiguration}.
......@@ -148,6 +151,17 @@ public class JmsAutoConfigurationTests {
assertTrue(jmsTemplate.isPubSubDomain());
}
@Test
public void testPubSubDomainActive() {
load(TestConfiguration.class, "spring.jms.pubSubDomain:true");
JmsTemplate jmsTemplate = this.context.getBean(JmsTemplate.class);
DefaultMessageListenerContainer defaultMessageListenerContainer = this.context
.getBean(DefaultJmsListenerContainerFactory.class)
.createListenerContainer(mock(JmsListenerEndpoint.class));
assertTrue(jmsTemplate.isPubSubDomain());
assertTrue(defaultMessageListenerContainer.isPubSubDomain());
}
@Test
public void testPubSubDomainOverride() {
load(TestConfiguration.class, "spring.jms.pubSubDomain:false");
......
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