Remove ConnectionFactorySettings configuration class

This resolves #386
This commit is contained in:
Ilayaperumal Gopinathan
2016-02-29 22:14:10 +05:30
committed by Marius Bogoevici
parent e5fdc971dd
commit 6a125b601b
2 changed files with 7 additions and 92 deletions

View File

@@ -1,81 +0,0 @@
/*
* Copyright 2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.stream.binder.rabbit;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.connection.RabbitConnectionFactoryBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.amqp.RabbitProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;
/**
* Configures the connection factory used by the rabbit binder.
*
* @author Eric Bottard
* @author Gary Russell
*/
@Configuration
public class ConnectionFactorySettings {
@Value("${spring.rabbitmq.useSSL:false}")
private boolean useSSL;
@Value("${spring.rabbitmq.sslProperties:}")
private Resource sslPropertiesLocation;
@Bean
public ConnectionFactory rabbitConnectionFactory(RabbitProperties config,
com.rabbitmq.client.ConnectionFactory rabbitConnectionFactory) throws Exception {
CachingConnectionFactory factory = new CachingConnectionFactory(rabbitConnectionFactory);
factory.setAddresses(config.getAddresses());
if (config.getHost() != null) {
factory.setHost(config.getHost());
factory.setPort(config.getPort());
}
if (config.getUsername() != null) {
factory.setUsername(config.getUsername());
}
if (config.getPassword() != null) {
factory.setPassword(config.getPassword());
}
if (config.getVirtualHost() != null) {
factory.setVirtualHost(config.getVirtualHost());
}
return factory;
}
// If no RabbitProperties bean is available, instantiate one, deferring to Spring Boot for populating it
@Configuration
@ConditionalOnMissingBean(RabbitProperties.class)
@EnableConfigurationProperties(RabbitProperties.class)
public static class RabbitPropertiesLoader {
}
@Bean
public RabbitConnectionFactoryBean rabbitFactory() {
RabbitConnectionFactoryBean rabbitConnectionFactoryBean = new RabbitConnectionFactoryBean();
rabbitConnectionFactoryBean.setUseSSL(this.useSSL);
rabbitConnectionFactoryBean.setSslPropertiesLocation(this.sslPropertiesLocation);
return rabbitConnectionFactoryBean;
}
}

View File

@@ -16,10 +16,6 @@
package org.springframework.cloud.stream.binder.rabbit.config;
/**
* @author David Turanski
*/
import org.springframework.amqp.core.MessagePostProcessor;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.support.postprocessor.DelegatingDecompressingPostProcessor;
@@ -27,7 +23,6 @@ import org.springframework.amqp.support.postprocessor.GZipPostProcessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.stream.binder.rabbit.ConnectionFactorySettings;
import org.springframework.cloud.stream.binder.rabbit.RabbitExtendedBindingProperties;
import org.springframework.cloud.stream.binder.rabbit.RabbitMessageChannelBinder;
import org.springframework.cloud.stream.config.codec.kryo.KryoCodecAutoConfiguration;
@@ -36,6 +31,13 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.integration.codec.Codec;
/**
* Configuration class for RabbitMQ message channel binder.
*
* @author David Turanski
*/
@Configuration
@Import({PropertyPlaceholderAutoConfiguration.class, KryoCodecAutoConfiguration.class})
@EnableConfigurationProperties({RabbitBinderConfigurationProperties.class, RabbitExtendedBindingProperties.class})
@@ -82,11 +84,5 @@ public class RabbitMessageChannelBinderConfiguration {
gZipPostProcessor.setLevel(rabbitBinderConfigurationProperties.getCompressionLevel());
return gZipPostProcessor;
}
@Bean
ConnectionFactorySettings rabbitConnectionFactorySettings() {
return new ConnectionFactorySettings();
}
}