/** * Sets the channel checkout timeout. When greater than 0, enables channel limiting * in that the {@link #channelCacheSize} becomes the total number of available channels per * connection rather than a simple cache size. Note that changing the {@link #channelCacheSize} * does not affect the limit on existing connection(s), invoke {@link #destroy()} to cause a * new connection to be created with the new limit. * <p> * Since 1.5.5, also applies to getting a connection when the cache mode is CONNECTION. * @param channelCheckoutTimeout the timeout in milliseconds; default 0 (channel limiting not enabled). * @since 1.4.2 * @see #setConnectionLimit(int) */ public void setChannelCheckoutTimeout(long channelCheckoutTimeout) { this.channelCheckoutTimeout = channelCheckoutTimeout; if (this.publisherConnectionFactory != null) { this.publisherConnectionFactory.setChannelCheckoutTimeout(channelCheckoutTimeout); } }
/** * Sets the channel checkout timeout. When greater than 0, enables channel limiting * in that the {@link #channelCacheSize} becomes the total number of available channels per * connection rather than a simple cache size. Note that changing the {@link #channelCacheSize} * does not affect the limit on existing connection(s), invoke {@link #destroy()} to cause a * new connection to be created with the new limit. * <p> * Since 1.5.5, also applies to getting a connection when the cache mode is CONNECTION. * @param channelCheckoutTimeout the timeout in milliseconds; default 0 (channel limiting not enabled). * @since 1.4.2 * @see #setConnectionLimit(int) */ public void setChannelCheckoutTimeout(long channelCheckoutTimeout) { this.channelCheckoutTimeout = channelCheckoutTimeout; if (this.publisherConnectionFactory != null) { this.publisherConnectionFactory.setChannelCheckoutTimeout(channelCheckoutTimeout); } }
@Bean CachingConnectionFactory connectionFactory() throws Exception { final ConnectionFactory cf = new ConnectionFactory(); cf.setUri("amqp://localhost"); final CachingConnectionFactory result = new CachingConnectionFactory(cf); result.setChannelCacheSize(2); result.setChannelCheckoutTimeout(2000); return result; }
ccf.setExecutor(mock(ExecutorService.class)); ccf.setChannelCacheSize(1); ccf.setChannelCheckoutTimeout(10);
ccf.setExecutor(mock(ExecutorService.class)); ccf.setChannelCacheSize(1); ccf.setChannelCheckoutTimeout(10000);
ccf.setConnectionCacheSize(1); ccf.setConnectionLimit(1); ccf.setChannelCheckoutTimeout(10); final CountDownLatch latch1 = new CountDownLatch(1); final AtomicReference<Connection> connection = new AtomicReference<Connection>(); ccf.setChannelCheckoutTimeout(30000); Executors.newSingleThreadExecutor().execute(() -> { latch1.countDown();
connectionFactory.setConnectionCacheSize(2); connectionFactory.setChannelCacheSize(1); connectionFactory.setChannelCheckoutTimeout(10); connectionFactory.setExecutor(Executors.newCachedThreadPool()); List<Connection> connections = new ArrayList<Connection>();
ccf.setExecutor(mock(ExecutorService.class)); ccf.setChannelCacheSize(1); ccf.setChannelCheckoutTimeout(10);
ccf.setExecutor(mock(ExecutorService.class)); ccf.setChannelCacheSize(1); ccf.setChannelCheckoutTimeout(10);
ccf.setExecutor(mock(ExecutorService.class)); ccf.setChannelCacheSize(2); ccf.setChannelCheckoutTimeout(10); ccf.setCacheMode(mode);
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(); }