Package org.apache.camel.spi
Interface ConsumerCache
- All Superinterfaces:
AutoCloseable
,Service
Cache containing created
PollingConsumer
.-
Method Summary
Modifier and TypeMethodDescriptionacquirePollingConsumer
(Endpoint endpoint) Acquires a pooled polling consumer which you must release back again after usage using thereleasePollingConsumer(Endpoint, PollingConsumer)
method.void
cleanUp()
Cleanup the cache (purging stale entries)int
Gets the maximum cache size (capacity).Gets the endpoint statisticsGets the source which uses this cachevoid
purge()
Purges this cacheWaits until a message is available and then returns it.Attempts to receive a message exchange, waiting up to the given timeout to expire if a message is not yet available.receiveNoWait
(Endpoint endpoint) Attempts to receive a message exchange immediately without waiting and returning null if a message exchange is not available yet.void
releasePollingConsumer
(Endpoint endpoint, PollingConsumer pollingConsumer) Releases an acquired polling consumer back after usage.int
size()
Returns the current size of the cache
-
Method Details
-
acquirePollingConsumer
Acquires a pooled polling consumer which you must release back again after usage using thereleasePollingConsumer(Endpoint, PollingConsumer)
method.- Parameters:
endpoint
- the endpoint- Returns:
- the consumer
-
releasePollingConsumer
Releases an acquired polling consumer back after usage.- Parameters:
endpoint
- the endpointpollingConsumer
- the consumer to release
-
receive
Waits until a message is available and then returns it. Warning that this method could block indefinitely if no messages are available. Will return null if the consumer is not started Important: See the class javadoc about the need for done theUnitOfWork
on the returnedExchange
- Parameters:
endpoint
- the endpoint to receive from- Returns:
- the message exchange received.
-
receive
Attempts to receive a message exchange, waiting up to the given timeout to expire if a message is not yet available. Important: See the class javadoc about the need for done theUnitOfWork
on the returnedExchange
- Parameters:
endpoint
- the endpoint to receive fromtimeout
- the amount of time in milliseconds to wait for a message before timing out and returning null- Returns:
- the message exchange if one was available within the timeout period, or null if the timeout expired
-
receiveNoWait
Attempts to receive a message exchange immediately without waiting and returning null if a message exchange is not available yet. Important: See the class javadoc about the need for done theUnitOfWork
on the returnedExchange
- Parameters:
endpoint
- the endpoint to receive from- Returns:
- the message exchange if one is immediately available otherwise null
-
getSource
Object getSource()Gets the source which uses this cache- Returns:
- the source
-
getCapacity
int getCapacity()Gets the maximum cache size (capacity).- Returns:
- the capacity
-
size
int size()Returns the current size of the cache- Returns:
- the current size
-
purge
void purge()Purges this cache -
cleanUp
void cleanUp()Cleanup the cache (purging stale entries) -
getEndpointUtilizationStatistics
EndpointUtilizationStatistics getEndpointUtilizationStatistics()Gets the endpoint statistics
-