Package org.mockserver.async.subscribe
Class BoundedMessageStore
java.lang.Object
org.mockserver.async.subscribe.BoundedMessageStore
A thread-safe, bounded FIFO store for
RecordedMessage instances.
When the store reaches its capacity, the oldest message is evicted to make room.
Uses a synchronized ArrayDeque internally — efficient O(1) add/evict,
and safe for concurrent producer (broker thread) + reader (control-plane HTTP thread)
patterns with a lock per-channel (not global).
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault maximum number of recorded messages per channel. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(RecordedMessage message) Add a message to the store.voidclear()Clear all messages.intsize()Return the current number of messages in the store.snapshot()Return a snapshot copy of all messages currently in the store.
-
Field Details
-
DEFAULT_MAX_RECORDED_MESSAGES
public static final int DEFAULT_MAX_RECORDED_MESSAGESDefault maximum number of recorded messages per channel.- See Also:
-
-
Constructor Details
-
BoundedMessageStore
public BoundedMessageStore() -
BoundedMessageStore
public BoundedMessageStore(int maxSize)
-
-
Method Details
-
add
Add a message to the store. If the store is at capacity, the oldest message is evicted (FIFO). Thread-safe. -
snapshot
Return a snapshot copy of all messages currently in the store. The returned list is independent of the store (safe to iterate without locking). -
size
public int size()Return the current number of messages in the store. -
clear
public void clear()Clear all messages.
-