|
|
|
@ -16,7 +16,6 @@
|
|
|
|
|
|
|
|
|
|
package org.springframework.boot.autoconfigure.jms.activemq;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import javax.jms.ConnectionFactory;
|
|
|
|
@ -49,46 +48,41 @@ import org.springframework.jms.connection.CachingConnectionFactory;
|
|
|
|
|
class ActiveMQConnectionFactoryConfiguration {
|
|
|
|
|
|
|
|
|
|
@Configuration
|
|
|
|
|
@ConditionalOnClass(CachingConnectionFactory.class)
|
|
|
|
|
@ConditionalOnProperty(prefix = "spring.activemq.pool", name = "enabled", havingValue = "false",
|
|
|
|
|
matchIfMissing = true)
|
|
|
|
|
static class SimpleConnectionFactoryConfiguration {
|
|
|
|
|
|
|
|
|
|
private final JmsProperties jmsProperties;
|
|
|
|
|
|
|
|
|
|
private final ActiveMQProperties properties;
|
|
|
|
|
|
|
|
|
|
private final List<ActiveMQConnectionFactoryCustomizer> connectionFactoryCustomizers;
|
|
|
|
|
|
|
|
|
|
SimpleConnectionFactoryConfiguration(JmsProperties jmsProperties, ActiveMQProperties properties,
|
|
|
|
|
ObjectProvider<ActiveMQConnectionFactoryCustomizer> connectionFactoryCustomizers) {
|
|
|
|
|
this.jmsProperties = jmsProperties;
|
|
|
|
|
this.properties = properties;
|
|
|
|
|
this.connectionFactoryCustomizers = connectionFactoryCustomizers.orderedStream()
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
@Bean
|
|
|
|
|
@ConditionalOnProperty(prefix = "spring.jms.cache", name = "enabled", havingValue = "false")
|
|
|
|
|
public ActiveMQConnectionFactory jmsConnectionFactory(ActiveMQProperties properties,
|
|
|
|
|
ObjectProvider<ActiveMQConnectionFactoryCustomizer> factoryCustomizers) {
|
|
|
|
|
return new ActiveMQConnectionFactoryFactory(properties,
|
|
|
|
|
factoryCustomizers.orderedStream().collect(Collectors.toList()))
|
|
|
|
|
.createConnectionFactory(ActiveMQConnectionFactory.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
@ConditionalOnClass(CachingConnectionFactory.class)
|
|
|
|
|
@ConditionalOnProperty(prefix = "spring.jms.cache", name = "enabled", havingValue = "true",
|
|
|
|
|
matchIfMissing = true)
|
|
|
|
|
public CachingConnectionFactory cachingJmsConnectionFactory() {
|
|
|
|
|
JmsProperties.Cache cacheProperties = this.jmsProperties.getCache();
|
|
|
|
|
CachingConnectionFactory connectionFactory = new CachingConnectionFactory(createConnectionFactory());
|
|
|
|
|
connectionFactory.setCacheConsumers(cacheProperties.isConsumers());
|
|
|
|
|
connectionFactory.setCacheProducers(cacheProperties.isProducers());
|
|
|
|
|
connectionFactory.setSessionCacheSize(cacheProperties.getSessionCacheSize());
|
|
|
|
|
return connectionFactory;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
@ConditionalOnProperty(prefix = "spring.jms.cache", name = "enabled", havingValue = "false")
|
|
|
|
|
public ActiveMQConnectionFactory jmsConnectionFactory() {
|
|
|
|
|
return createConnectionFactory();
|
|
|
|
|
}
|
|
|
|
|
static class CachingConnectionFactoryConfiguration {
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
@ConditionalOnProperty(prefix = "spring.jms.cache", name = "enabled", havingValue = "true",
|
|
|
|
|
matchIfMissing = true)
|
|
|
|
|
public CachingConnectionFactory cachingJmsConnectionFactory(JmsProperties jmsProperties,
|
|
|
|
|
ActiveMQProperties properties,
|
|
|
|
|
ObjectProvider<ActiveMQConnectionFactoryCustomizer> factoryCustomizers) {
|
|
|
|
|
JmsProperties.Cache cacheProperties = jmsProperties.getCache();
|
|
|
|
|
CachingConnectionFactory connectionFactory = new CachingConnectionFactory(
|
|
|
|
|
new ActiveMQConnectionFactoryFactory(properties,
|
|
|
|
|
factoryCustomizers.orderedStream().collect(Collectors.toList()))
|
|
|
|
|
.createConnectionFactory(ActiveMQConnectionFactory.class));
|
|
|
|
|
connectionFactory.setCacheConsumers(cacheProperties.isConsumers());
|
|
|
|
|
connectionFactory.setCacheProducers(cacheProperties.isProducers());
|
|
|
|
|
connectionFactory.setSessionCacheSize(cacheProperties.getSessionCacheSize());
|
|
|
|
|
return connectionFactory;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ActiveMQConnectionFactory createConnectionFactory() {
|
|
|
|
|
return new ActiveMQConnectionFactoryFactory(this.properties, this.connectionFactoryCustomizers)
|
|
|
|
|
.createConnectionFactory(ActiveMQConnectionFactory.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -98,8 +92,7 @@ class ActiveMQConnectionFactoryConfiguration {
|
|
|
|
|
static class PooledConnectionFactoryConfiguration {
|
|
|
|
|
|
|
|
|
|
@Bean(destroyMethod = "stop")
|
|
|
|
|
@ConditionalOnProperty(prefix = "spring.activemq.pool", name = "enabled", havingValue = "true",
|
|
|
|
|
matchIfMissing = false)
|
|
|
|
|
@ConditionalOnProperty(prefix = "spring.activemq.pool", name = "enabled", havingValue = "true")
|
|
|
|
|
public JmsPoolConnectionFactory pooledJmsConnectionFactory(ActiveMQProperties properties,
|
|
|
|
|
ObjectProvider<ActiveMQConnectionFactoryCustomizer> factoryCustomizers) {
|
|
|
|
|
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactoryFactory(properties,
|
|
|
|
|