|
|
|
@ -26,6 +26,7 @@ import org.apache.activemq.pool.PooledConnectionFactory;
|
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
|
|
|
import org.springframework.boot.jta.XAConnectionFactoryWrapper;
|
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
@ -53,15 +54,25 @@ class ActiveMQXAConnectionFactoryConfiguration {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
public ConnectionFactory nonXaJmsConnectionFactory(ActiveMQProperties properties) {
|
|
|
|
|
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactoryFactory(
|
|
|
|
|
properties).createConnectionFactory(ActiveMQConnectionFactory.class);
|
|
|
|
|
if (properties.isPooled()) {
|
|
|
|
|
PooledConnectionFactory pool = new PooledConnectionFactory();
|
|
|
|
|
pool.setConnectionFactory(connectionFactory);
|
|
|
|
|
return pool;
|
|
|
|
|
@ConditionalOnProperty(prefix = "spring.activemq", name = "pooled", havingValue = "false", matchIfMissing = true)
|
|
|
|
|
public ActiveMQConnectionFactory nonXaJmsConnectionFactory(
|
|
|
|
|
ActiveMQProperties properties) {
|
|
|
|
|
return new ActiveMQConnectionFactoryFactory(properties)
|
|
|
|
|
.createConnectionFactory(ActiveMQConnectionFactory.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ConditionalOnClass(PooledConnectionFactory.class)
|
|
|
|
|
@ConditionalOnProperty(prefix = "spring.activemq", name = "pooled", havingValue = "true", matchIfMissing = false)
|
|
|
|
|
static class PooledConnectionFactoryConfiguration {
|
|
|
|
|
|
|
|
|
|
@Bean(destroyMethod = "stop")
|
|
|
|
|
public PooledConnectionFactory pooledNonXaJmsConnectionFactory(
|
|
|
|
|
ActiveMQProperties properties) {
|
|
|
|
|
return new PooledConnectionFactory(
|
|
|
|
|
new ActiveMQConnectionFactoryFactory(properties)
|
|
|
|
|
.createConnectionFactory(ActiveMQConnectionFactory.class));
|
|
|
|
|
}
|
|
|
|
|
return connectionFactory;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|