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.voidcleanUp()Cleanup the cache (purging stale entries)intGets the maximum cache size (capacity).@Nullable EndpointUtilizationStatisticsGets the endpoint statisticsGets the source which uses this cachevoidpurge()Purges this cache@Nullable ExchangeWaits until a message is available and then returns it.@Nullable ExchangeAttempts to receive a message exchange, waiting up to the given timeout to expire if a message is not yet available.@Nullable ExchangereceiveNoWait(Endpoint endpoint) Attempts to receive a message exchange immediately without waiting and returning null if a message exchange is not available yet.voidreleasePollingConsumer(Endpoint endpoint, PollingConsumer pollingConsumer) Releases an acquired polling consumer back after usage.intsize()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 theUnitOfWorkon 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 theUnitOfWorkon 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 theUnitOfWorkon the returnedExchange- Parameters:
endpoint- the endpoint to receive from- Returns:
- the message exchange if one is immediately available otherwise null
-
getSource
-
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
@Nullable EndpointUtilizationStatistics getEndpointUtilizationStatistics()Gets the endpoint statistics
-