I have created below bean in spring 4. Currently declared HOST and other variable in this below configuration file as static. But want to get it from database dynamically. Not able to find a way how to get it.
Please suggest what is the way to get it from database.
@Configuration
public class RabbitMqConfiguration {
public static final String HOST = "localhost";
public static final String USERNAME = "test";
public static final String PASSWORD = "test";
public static final int CHANNEL_CACHE_SIZE = 25;
public static final int CONNECTION_CLOSE_TIMEOUT = 30000;
public static final int CONNECTION_CACHE_SIZE = 1;
public static final int REQUEST_HEART_BEAT = 0;
@Bean
public ConnectionFactory connectionFactory() {
CachingConnectionFactory connectionFactory = new CachingConnectionFactory(HOST);
connectionFactory.setUsername(USERNAME);
connectionFactory.setPassword(PASSWORD);
connectionFactory.setCloseTimeout(CONNECTION_CLOSE_TIMEOUT);
connectionFactory.setChannelCacheSize(CHANNEL_CACHE_SIZE);
connectionFactory.setConnectionCacheSize(CONNECTION_CACHE_SIZE);
connectionFactory.setRequestedHeartBeat(REQUEST_HEART_BEAT);
return connectionFactory;
}
}