Interface ConsumerCache

All Superinterfaces:
AutoCloseable, Service

public interface ConsumerCache extends Service
Cache containing created PollingConsumer.
  • Method Details

    • acquirePollingConsumer

      PollingConsumer acquirePollingConsumer(Endpoint endpoint)
      Acquires a pooled polling consumer which you must release back again after usage using the releasePollingConsumer(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 endpoint
      pollingConsumer - 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 the UnitOfWork on the returned Exchange

      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 the UnitOfWork on the returned Exchange

      Parameters:
      endpoint - the endpoint to receive from
      timeout - 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 the UnitOfWork on the returned Exchange

      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