Class LimitedMemoryExchangeStore

java.lang.Object
com.predic8.membrane.core.exchangestore.AbstractExchangeStore
com.predic8.membrane.core.exchangestore.LimitedMemoryExchangeStore
All Implemented Interfaces:
ExchangeStore

public class LimitedMemoryExchangeStore extends AbstractExchangeStore
Description
Stores exchange objects in-memory until a memory threshold is reached. When the threshold is reached and new exchanges arrive then old exchanges will be dropped (starting from oldest ascending) until the exchange can be stored. The LimitedMemoryExchangeStore is the default ExchangeStore Membrane uses.
  • Constructor Details

    • LimitedMemoryExchangeStore

      public LimitedMemoryExchangeStore()
  • Method Details

    • snap

      public void snap(AbstractExchange exc, Interceptor.Flow flow)
      Description copied from interface: ExchangeStore
      Adds the current state of the exchange to the store.

      Implementations should take a snapshot of the current state of the request (or response) headers and register a body observer in which they will be called back as soon as the body has fully been received.

      If flow==REQUEST, the request is added. Elsewise, the response is added (if present).

    • remove

      public void remove(AbstractExchange exc)
    • removeAllExchanges

      public void removeAllExchanges(Rule rule)
    • getExchanges

      public AbstractExchange[] getExchanges(RuleKey ruleKey)
    • getNumberOfExchanges

      public int getNumberOfExchanges(RuleKey ruleKey)
    • getStatistics

      public StatisticCollector getStatistics(RuleKey key)
    • getAllExchanges

      public Object[] getAllExchanges()
    • getAllExchangesAsList

      public List<AbstractExchange> getAllExchangesAsList()
    • removeAllExchanges

      public void removeAllExchanges(AbstractExchange[] candidates)
    • getExchangeById

      public AbstractExchange getExchangeById(long id)
      Specified by:
      getExchangeById in interface ExchangeStore
      Overrides:
      getExchangeById in class AbstractExchangeStore
    • search

      public List<AbstractExchange> search(String e)
    • getClientStatistics

      public List<? extends ClientStatistics> getClientStatistics()
      Specified by:
      getClientStatistics in interface ExchangeStore
      Overrides:
      getClientStatistics in class AbstractExchangeStore
    • getCurrentSize

      public int getCurrentSize()
    • getOldestTimeResSent

      public Long getOldestTimeResSent()
    • getMaxSize

      public int getMaxSize()
    • setMaxSize

      public void setMaxSize(int maxSize)
      Default
      1000000
      Description
      Threshold limit in bytes until old exchanges are dropped.
      Example
      1048576(1Mb)
    • getLastModified

      public long getLastModified()
      Specified by:
      getLastModified in interface ExchangeStore
      Overrides:
      getLastModified in class AbstractExchangeStore
    • waitForModification

      public void waitForModification(long lastKnownModification) throws InterruptedException
      Description copied from interface: ExchangeStore
      Returns immediately if lastKnownModification is smaller than last known modification. Otherwise it waits until a modification occurs.
      Specified by:
      waitForModification in interface ExchangeStore
      Overrides:
      waitForModification in class AbstractExchangeStore
      Throws:
      InterruptedException
    • getMaxBodySize

      public int getMaxBodySize()
    • setMaxBodySize

      public void setMaxBodySize(int maxBodySize)
      Default
      100000
      Description

      Maximum body size limit in bytes. If bodies are collected, which exceed this limit, the strategy determines, what happens.

    • getBodyExceedingMaxSizeStrategy

      public BodyCollectingMessageObserver.Strategy getBodyExceedingMaxSizeStrategy()
    • setBodyExceedingMaxSizeStrategy

      public void setBodyExceedingMaxSizeStrategy(BodyCollectingMessageObserver.Strategy bodyExceedingMaxSizeStrategy)
      Default
      TRUNCATE
      Description
      The strategy to use (TRUNCATE or ERROR) when a HTTP message body is larger than the maxBodySize. TRUNCATE means that only the first bytes are kept in memory. ERROR means that HTTP requests exceeding this limit will cause an error and not be processed any further: If the request exceeds the limit, it will not be processed further; if the response exceeds the limit, it will not be processed further. ("Further processing" usually includes transmission over a network.)