package in.gov.digilocker.uidai.logs.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.rabbitmq.client.ConnectionFactory;

@Configuration
public class RabbitConfiguration {
	
	@Autowired RabbitMQConfiguration rabbitMqConfig;
	
	@Bean
	public ConnectionFactory connectionFactory() {
		ConnectionFactory factory= new ConnectionFactory();		
		factory.setUsername(rabbitMqConfig.getRabbitMqUsername());
		factory.setPassword(rabbitMqConfig.getRabbitMqPassword());
		factory.setHost(rabbitMqConfig.getRabbitMqHost());
		factory.setPort(rabbitMqConfig.getRabbitMqPort());				
		factory.setAutomaticRecoveryEnabled(true);
		factory.setRequestedHeartbeat(5);
        factory.setConnectionTimeout(1000);
        
		factory.setNetworkRecoveryInterval(rabbitMqConfig.getRabbitMqNetworkREcoveryInterval());
		return factory; 		
	}
}
