@ -44,41 +44,40 @@ import org.springframework.jms.connection.CachingConnectionFactory;
class ArtemisConnectionFactoryConfiguration {
class ArtemisConnectionFactoryConfiguration {
@Configuration ( proxyBeanMethods = false )
@Configuration ( proxyBeanMethods = false )
@ConditionalOnClass ( CachingConnectionFactory . class )
@ConditionalOnProperty ( prefix = "spring.artemis.pool" , name = "enabled" , havingValue = "false" ,
@ConditionalOnProperty ( prefix = "spring.artemis.pool" , name = "enabled" , havingValue = "false" ,
matchIfMissing = true )
matchIfMissing = true )
static class SimpleConnectionFactoryConfiguration {
static class SimpleConnectionFactoryConfiguration {
private final ArtemisProperties properties ;
@Bean ( name = "jmsConnectionFactory" )
@ConditionalOnProperty ( prefix = "spring.jms.cache" , name = "enabled" , havingValue = "false" )
private final ListableBeanFactory beanFactory ;
ActiveMQConnectionFactory jmsConnectionFactory ( ArtemisProperties properties , ListableBeanFactory beanFactory ) {
return createConnectionFactory ( properties , beanFactory ) ;
}
SimpleConnectionFactoryConfiguration ( ArtemisProperties properties , ListableBeanFactory beanFactory ) {
private static ActiveMQConnectionFactory createConnectionFactory ( ArtemisProperties properties ,
this . properties = properties ;
ListableBeanFactory beanFactory ) {
this . beanFactory = beanFactory ;
return new ArtemisConnectionFactoryFactory ( beanFactory , properties )
. createConnectionFactory ( ActiveMQConnectionFactory . class ) ;
}
}
@Bean ( name = "jmsConnectionFactory" )
@Configuration ( proxyBeanMethods = false )
@ConditionalOnClass ( CachingConnectionFactory . class )
@ConditionalOnProperty ( prefix = "spring.jms.cache" , name = "enabled" , havingValue = "true" ,
@ConditionalOnProperty ( prefix = "spring.jms.cache" , name = "enabled" , havingValue = "true" ,
matchIfMissing = true )
matchIfMissing = true )
CachingConnectionFactory cachingJmsConnectionFactory ( JmsProperties jmsProperties ) {
static class CachingConnectionFactoryConfiguration {
@Bean ( name = "jmsConnectionFactory" )
CachingConnectionFactory cachingJmsConnectionFactory ( JmsProperties jmsProperties ,
ArtemisProperties properties , ListableBeanFactory beanFactory ) {
JmsProperties . Cache cacheProperties = jmsProperties . getCache ( ) ;
JmsProperties . Cache cacheProperties = jmsProperties . getCache ( ) ;
CachingConnectionFactory connectionFactory = new CachingConnectionFactory ( createConnectionFactory ( ) ) ;
CachingConnectionFactory connectionFactory = new CachingConnectionFactory (
createConnectionFactory ( properties , beanFactory ) ) ;
connectionFactory . setCacheConsumers ( cacheProperties . isConsumers ( ) ) ;
connectionFactory . setCacheConsumers ( cacheProperties . isConsumers ( ) ) ;
connectionFactory . setCacheProducers ( cacheProperties . isProducers ( ) ) ;
connectionFactory . setCacheProducers ( cacheProperties . isProducers ( ) ) ;
connectionFactory . setSessionCacheSize ( cacheProperties . getSessionCacheSize ( ) ) ;
connectionFactory . setSessionCacheSize ( cacheProperties . getSessionCacheSize ( ) ) ;
return connectionFactory ;
return connectionFactory ;
}
}
@Bean ( name = "jmsConnectionFactory" )
@ConditionalOnProperty ( prefix = "spring.jms.cache" , name = "enabled" , havingValue = "false" )
ActiveMQConnectionFactory jmsConnectionFactory ( ) {
return createConnectionFactory ( ) ;
}
private ActiveMQConnectionFactory createConnectionFactory ( ) {
return new ArtemisConnectionFactoryFactory ( this . beanFactory , this . properties )
. createConnectionFactory ( ActiveMQConnectionFactory . class ) ;
}
}
}
}