Package org.apache.camel.spi
Interface ConsumerCache
-
- All Superinterfaces:
AutoCloseable
,Service
public interface ConsumerCache extends Service
Cache containing createdPollingConsumer
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description PollingConsumer
acquirePollingConsumer(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
getCapacity()
Gets the maximum cache size (capacity).EndpointUtilizationStatistics
getEndpointUtilizationStatistics()
Gets the endpoint statisticsObject
getSource()
Gets the source which uses this cachevoid
purge()
Purges this cacheExchange
receive(Endpoint endpoint)
Waits until a message is available and then returns it.Exchange
receive(Endpoint endpoint, long timeout)
Attempts to receive a message exchange, waiting up to the given timeout to expire if a message is not yet available.Exchange
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 Detail
-
acquirePollingConsumer
PollingConsumer acquirePollingConsumer(Endpoint endpoint)
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
void releasePollingConsumer(Endpoint endpoint, PollingConsumer pollingConsumer)
Releases an acquired polling consumer back after usage.- Parameters:
endpoint
- the endpointpollingConsumer
- the consumer to release
-
receive
Exchange receive(Endpoint endpoint)
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
Exchange receive(Endpoint endpoint, long timeout)
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
Exchange receiveNoWait(Endpoint endpoint)
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
-
-