public ProducerCache(Object source, CamelContext camelContext, ServicePool<Endpoint, Producer> producerServicePool, Map<String, Producer> cache) { this.source = source; this.camelContext = camelContext; if (producerServicePool == null) { // use shared producer pool which lifecycle is managed by CamelContext this.pool = camelContext.getProducerServicePool(); this.stopServicePool = false; } else { this.pool = producerServicePool; this.stopServicePool = true; } this.producers = cache; if (producers instanceof LRUCache) { maxCacheSize = ((LRUCache) producers).getMaxCacheSize(); } // only if JMX is enabled if (camelContext.getManagementStrategy().getManagementAgent() != null) { this.extendedStatistics = camelContext.getManagementStrategy().getManagementAgent().getStatisticsLevel().isExtended(); } else { this.extendedStatistics = false; } }
public ConsumerCache(Object source, CamelContext camelContext, Map<String, PollingConsumer> cache, ServicePool<Endpoint, PollingConsumer> pool) { this.camelContext = camelContext; this.consumers = cache; this.source = source; this.pool = pool; if (consumers instanceof LRUCache) { maxCacheSize = ((LRUCache) consumers).getMaxCacheSize(); } // only if JMX is enabled if (camelContext.getManagementStrategy().getManagementAgent() != null) { this.extendedStatistics = camelContext.getManagementStrategy().getManagementAgent().getStatisticsLevel().isExtended(); } else { this.extendedStatistics = false; } }
public void setProducerServicePool(ServicePool<Endpoint, Producer> producerServicePool) { this.producerServicePool = producerServicePool; }
public ServicePool<Endpoint, Producer> getProducerServicePool() { return producerServicePool; }
public ServicePool<Endpoint, PollingConsumer> getPollingConsumerServicePool() { return pollingConsumerServicePool; }
public void setPollingConsumerServicePool(ServicePool<Endpoint, PollingConsumer> pollingConsumerServicePool) { this.pollingConsumerServicePool = pollingConsumerServicePool; }
public void testSharedProducerServicePoolHitMax() throws Exception { // the default capacity assertEquals(100, context.getProducerServicePool().getCapacity()); // change it ServicePool<Endpoint, Producer> pool = context.getProducerServicePool(); pool.setCapacity(3); assertEquals(3, pool.getCapacity()); Endpoint endpoint = context.getEndpoint("mock:foo"); assertNull(pool.acquire(endpoint)); assertEquals(0, pool.size()); Producer producer = new MyProducer(endpoint); producer = pool.addAndAcquire(endpoint, producer); assertEquals(0, pool.size()); Producer producer2 = new MyProducer(endpoint); producer2 = pool.addAndAcquire(endpoint, producer2); assertEquals(0, pool.size()); Producer producer3 = new MyProducer(endpoint); producer3 = pool.addAndAcquire(endpoint, producer3); assertEquals(0, pool.size()); pool.release(endpoint, producer); assertEquals(1, pool.size()); pool.release(endpoint, producer2); assertEquals(2, pool.size()); pool.release(endpoint, producer3); assertEquals(3, pool.size()); Producer producer4 = new MyProducer(endpoint); try { producer4 = pool.addAndAcquire(endpoint, producer4); fail("Should throw an exception"); } catch (IllegalStateException e) { assertEquals("Queue full", e.getMessage()); } assertEquals(3, pool.size()); }
@Override public void setProducerServicePool(ServicePool<Endpoint, Producer> servicePool) { context.setProducerServicePool(servicePool); }
@Override public ServicePool<Endpoint, Producer> getProducerServicePool() { return context.getProducerServicePool(); }
@Override public void setPollingConsumerServicePool(ServicePool<Endpoint, PollingConsumer> servicePool) { context.setPollingConsumerServicePool(servicePool); }
@Override public ServicePool<Endpoint, PollingConsumer> getPollingConsumerServicePool() { return context.getPollingConsumerServicePool(); }
/** * Sets a pluggable service pool to use for {@link Producer} pooling. * * @param servicePool the pool */ void setProducerServicePool(ServicePool<Endpoint, Producer> servicePool);
/** * Gets the service pool for {@link Producer} pooling. * * @return the service pool */ ServicePool<Endpoint, Producer> getProducerServicePool();
/** * Sets a pluggable service pool to use for {@link PollingConsumer} pooling. * * @param servicePool the pool */ void setPollingConsumerServicePool(ServicePool<Endpoint, PollingConsumer> servicePool);
/** * Gets the service pool for {@link Producer} pooling. * * @return the service pool */ ServicePool<Endpoint, PollingConsumer> getPollingConsumerServicePool();