@Override public void afterPropertiesSet() { this.initialized = true; if (this.cacheMode == CacheMode.CHANNEL) { Assert.isTrue(this.connectionCacheSize == 1, "When the cache mode is 'CHANNEL', the connection cache size cannot be configured."); } initCacheWaterMarks(); if (this.publisherConnectionFactory != null) { this.publisherConnectionFactory.afterPropertiesSet(); } }
@Override public void afterPropertiesSet() { this.initialized = true; if (this.cacheMode == CacheMode.CHANNEL) { Assert.isTrue(this.connectionCacheSize == 1, "When the cache mode is 'CHANNEL', the connection cache size cannot be configured."); } initCacheWaterMarks(); if (this.publisherConnectionFactory != null) { this.publisherConnectionFactory.afterPropertiesSet(); } }
@Override public CachingConnectionFactory rabbitConnectionFactory(RabbitProperties config, ObjectProvider<ConnectionNameStrategy> connectionNameStrategy) throws Exception { CachingConnectionFactory cf = super.rabbitConnectionFactory(config, connectionNameStrategy); cf.setConnectionNameStrategy(new ConnectionNameStrategy() { @Override public String obtainNewConnectionName(ConnectionFactory connectionFactory) { return "rabbit.source.own.connection"; } }); cf.afterPropertiesSet(); return cf; }
@Override public CachingConnectionFactory rabbitConnectionFactory(RabbitProperties config, ObjectProvider<ConnectionNameStrategy> connectionNameStrategy) throws Exception { CachingConnectionFactory cf = super.rabbitConnectionFactory(config, connectionNameStrategy); cf.setConnectionNameStrategy(new ConnectionNameStrategy() { @Override public String obtainNewConnectionName(ConnectionFactory connectionFactory) { return "rabbit.sink.own.connection"; } }); cf.afterPropertiesSet(); return cf; }
ccf.setCacheMode(CacheMode.CONNECTION); ccf.setConnectionCacheSize(5); ccf.afterPropertiesSet();
ccf.setExecutor(mock(ExecutorService.class)); ccf.setCacheMode(CacheMode.CONNECTION); ccf.afterPropertiesSet();
ccf.setConnectionCacheSize(2); ccf.setChannelCacheSize(2); ccf.afterPropertiesSet();
static void configureCachingConnectionFactory(CachingConnectionFactory connectionFactory, ConfigurableApplicationContext applicationContext, RabbitProperties rabbitProperties) throws Exception { if (StringUtils.hasText(rabbitProperties.getAddresses())) { connectionFactory.setAddresses(rabbitProperties.determineAddresses()); } connectionFactory.setPublisherConfirms(rabbitProperties.isPublisherConfirms()); connectionFactory.setPublisherReturns(rabbitProperties.isPublisherReturns()); if (rabbitProperties.getCache().getChannel().getSize() != null) { connectionFactory.setChannelCacheSize(rabbitProperties.getCache().getChannel().getSize()); } if (rabbitProperties.getCache().getConnection().getMode() != null) { connectionFactory.setCacheMode(rabbitProperties.getCache().getConnection().getMode()); } if (rabbitProperties.getCache().getConnection().getSize() != null) { connectionFactory.setConnectionCacheSize( rabbitProperties.getCache().getConnection().getSize()); } if (rabbitProperties.getCache().getChannel().getCheckoutTimeout() != null) { connectionFactory.setChannelCheckoutTimeout( rabbitProperties.getCache().getChannel().getCheckoutTimeout().toMillis()); } connectionFactory.setApplicationContext(applicationContext); applicationContext.addApplicationListener(connectionFactory); connectionFactory.afterPropertiesSet(); }
static void configureCachingConnectionFactory(CachingConnectionFactory connectionFactory, ConfigurableApplicationContext applicationContext, RabbitProperties rabbitProperties) throws Exception { if (StringUtils.hasText(rabbitProperties.getAddresses())) { connectionFactory.setAddresses(rabbitProperties.determineAddresses()); } connectionFactory.setPublisherConfirms(rabbitProperties.isPublisherConfirms()); connectionFactory.setPublisherReturns(rabbitProperties.isPublisherReturns()); if (rabbitProperties.getCache().getChannel().getSize() != null) { connectionFactory.setChannelCacheSize(rabbitProperties.getCache().getChannel().getSize()); } if (rabbitProperties.getCache().getConnection().getMode() != null) { connectionFactory.setCacheMode(rabbitProperties.getCache().getConnection().getMode()); } if (rabbitProperties.getCache().getConnection().getSize() != null) { connectionFactory.setConnectionCacheSize( rabbitProperties.getCache().getConnection().getSize()); } if (rabbitProperties.getCache().getChannel().getCheckoutTimeout() != null) { connectionFactory.setChannelCheckoutTimeout( rabbitProperties.getCache().getChannel().getCheckoutTimeout().toMillis()); } connectionFactory.setApplicationContext(applicationContext); applicationContext.addApplicationListener(connectionFactory); connectionFactory.afterPropertiesSet(); }