|
|
|
|
@ -16,7 +16,6 @@
@@ -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,43 +48,42 @@ import org.springframework.jms.connection.CachingConnectionFactory;
@@ -49,43 +48,42 @@ import org.springframework.jms.connection.CachingConnectionFactory;
|
|
|
|
|
class ActiveMQConnectionFactoryConfiguration { |
|
|
|
|
|
|
|
|
|
@Configuration(proxyBeanMethods = false) |
|
|
|
|
@ConditionalOnClass(CachingConnectionFactory.class) |
|
|
|
|
@ConditionalOnProperty(prefix = "spring.activemq.pool", name = "enabled", havingValue = "false", |
|
|
|
|
matchIfMissing = true) |
|
|
|
|
static class SimpleConnectionFactoryConfiguration { |
|
|
|
|
|
|
|
|
|
private final ActiveMQProperties properties; |
|
|
|
|
|
|
|
|
|
private final List<ActiveMQConnectionFactoryCustomizer> connectionFactoryCustomizers; |
|
|
|
|
|
|
|
|
|
SimpleConnectionFactoryConfiguration(ActiveMQProperties properties, |
|
|
|
|
ObjectProvider<ActiveMQConnectionFactoryCustomizer> connectionFactoryCustomizers) { |
|
|
|
|
this.properties = properties; |
|
|
|
|
this.connectionFactoryCustomizers = connectionFactoryCustomizers.orderedStream() |
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
@Bean |
|
|
|
|
@ConditionalOnProperty(prefix = "spring.jms.cache", name = "enabled", havingValue = "false") |
|
|
|
|
ActiveMQConnectionFactory jmsConnectionFactory(ActiveMQProperties properties, |
|
|
|
|
ObjectProvider<ActiveMQConnectionFactoryCustomizer> factoryCustomizers) { |
|
|
|
|
return new ActiveMQConnectionFactoryFactory(properties, |
|
|
|
|
factoryCustomizers.orderedStream().collect(Collectors.toList())) |
|
|
|
|
.createConnectionFactory(ActiveMQConnectionFactory.class); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Bean |
|
|
|
|
@Configuration(proxyBeanMethods = false) |
|
|
|
|
@ConditionalOnClass(CachingConnectionFactory.class) |
|
|
|
|
@ConditionalOnProperty(prefix = "spring.jms.cache", name = "enabled", havingValue = "true", |
|
|
|
|
matchIfMissing = true) |
|
|
|
|
CachingConnectionFactory cachingJmsConnectionFactory(JmsProperties jmsProperties) { |
|
|
|
|
JmsProperties.Cache cacheProperties = 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") |
|
|
|
|
ActiveMQConnectionFactory jmsConnectionFactory() { |
|
|
|
|
return createConnectionFactory(); |
|
|
|
|
} |
|
|
|
|
static class CachingConnectionFactoryConfiguration { |
|
|
|
|
|
|
|
|
|
@Bean |
|
|
|
|
@ConditionalOnProperty(prefix = "spring.jms.cache", name = "enabled", havingValue = "true", |
|
|
|
|
matchIfMissing = true) |
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
@ -95,8 +93,7 @@ class ActiveMQConnectionFactoryConfiguration {
@@ -95,8 +93,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") |
|
|
|
|
JmsPoolConnectionFactory pooledJmsConnectionFactory(ActiveMQProperties properties, |
|
|
|
|
ObjectProvider<ActiveMQConnectionFactoryCustomizer> factoryCustomizers) { |
|
|
|
|
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactoryFactory(properties, |
|
|
|
|
|