public class ConsumerCache extends ServiceSupport
Consumer
.shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending
Constructor and Description |
---|
ConsumerCache(Object source,
CamelContext camelContext) |
ConsumerCache(Object source,
CamelContext camelContext,
int cacheSize) |
ConsumerCache(Object source,
CamelContext camelContext,
Map<String,PollingConsumer> cache) |
ConsumerCache(Object source,
CamelContext camelContext,
Map<String,PollingConsumer> cache,
ServicePool<Endpoint,PollingConsumer> pool) |
Modifier and Type | Method and Description |
---|---|
PollingConsumer |
acquirePollingConsumer(Endpoint endpoint)
Acquires a pooled PollingConsumer which you must release back again after usage using the
releasePollingConsumer(org.apache.camel.Endpoint, org.apache.camel.PollingConsumer) method. |
protected static LRUCache<String,PollingConsumer> |
createLRUCache(int cacheSize)
Creates the
LRUCache to be used. |
protected PollingConsumer |
doGetPollingConsumer(Endpoint endpoint,
boolean pooled) |
protected void |
doStart()
Implementations override this method to support customized start/stop.
|
protected void |
doStop()
Implementations override this method to support customized start/stop.
|
CamelContext |
getCamelContext() |
int |
getCapacity()
Gets the maximum cache size (capacity).
|
PollingConsumer |
getConsumer(Endpoint endpoint) |
long |
getEvicted()
Gets the cache evicted statistic
Will return -1 if it cannot determine this if a custom cache was used.
|
long |
getHits()
Gets the cache hits statistic
Will return -1 if it cannot determine this if a custom cache was used.
|
long |
getMisses()
Gets the cache misses statistic
Will return -1 if it cannot determine this if a custom cache was used.
|
Object |
getSource()
Gets the source which uses this cache
|
void |
purge()
Purges this cache
|
Exchange |
receive(Endpoint endpoint) |
Exchange |
receive(Endpoint endpoint,
long timeout) |
Exchange |
receiveNoWait(Endpoint endpoint) |
void |
releasePollingConsumer(Endpoint endpoint,
PollingConsumer pollingConsumer)
Releases an acquired producer back after usage.
|
void |
resetCacheStatistics()
Resets the cache statistics
|
int |
size()
Returns the current size of the cache
|
String |
toString() |
doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, resume, shutdown, start, stop, suspend
public ConsumerCache(Object source, CamelContext camelContext)
public ConsumerCache(Object source, CamelContext camelContext, int cacheSize)
public ConsumerCache(Object source, CamelContext camelContext, Map<String,PollingConsumer> cache)
public ConsumerCache(Object source, CamelContext camelContext, Map<String,PollingConsumer> cache, ServicePool<Endpoint,PollingConsumer> pool)
protected static LRUCache<String,PollingConsumer> createLRUCache(int cacheSize)
cacheSize
- the cache sizepublic PollingConsumer acquirePollingConsumer(Endpoint endpoint)
releasePollingConsumer(org.apache.camel.Endpoint, org.apache.camel.PollingConsumer)
method.endpoint
- the endpointpublic void releasePollingConsumer(Endpoint endpoint, PollingConsumer pollingConsumer)
endpoint
- the endpointpollingConsumer
- the pollingConsumer to releasepublic PollingConsumer getConsumer(Endpoint endpoint)
protected PollingConsumer doGetPollingConsumer(Endpoint endpoint, boolean pooled)
public Exchange receiveNoWait(Endpoint endpoint)
public CamelContext getCamelContext()
public int size()
public int getCapacity()
public long getHits()
public long getMisses()
public long getEvicted()
public void resetCacheStatistics()
public void purge()
protected void doStart() throws Exception
ServiceSupport
ServiceSupport.doStop()
for more details.doStart
in class ServiceSupport
Exception
ServiceSupport.doStop()
protected void doStop() throws Exception
ServiceSupport
ServiceSupport.doStop()
method when
the service is being stopped. This method will also be invoked
if the service is still in uninitialized state (eg has not
been started). The method is always called to allow the service
to do custom logic when the service is being stopped, such as when
CamelContext
is shutting down.doStop
in class ServiceSupport
Exception
ServiceSupport.doStart()
Apache Camel