@ThreadSafe public class CompactingConcurrentMapMessageStore extends java.lang.Object implements MessageStore
key.
The ordering of messages is guaranteed by using a (on-heap) ConcurrentSkipListSet for keys.
The messages are stored in a ConcurrentMap like, for example, ChronicleMap. This way, the messages can be stored off-heap, so large numbers of messages can be stored in memory, without getting problems with Java garbage-collecting.
| Constructor and Description |
|---|
CompactingConcurrentMapMessageStore() |
CompactingConcurrentMapMessageStore(boolean removeNullPayloadMessages) |
CompactingConcurrentMapMessageStore(boolean removeNullPayloadMessages,
java.util.concurrent.ConcurrentMap<java.lang.String,java.io.Serializable> messageMap) |
| Modifier and Type | Method and Description |
|---|---|
void |
add(Message<java.lang.String> message) |
ChannelPosition |
getLatestChannelPosition()
Returns the latest
ChannelPosition of the MessageStore. |
int |
size()
Returns the number of messages contained in the MessageStore.
|
java.util.stream.Stream<Message<java.lang.String>> |
stream()
Returns a Stream of
messages contained in the MessageStore. |
public CompactingConcurrentMapMessageStore()
public CompactingConcurrentMapMessageStore(boolean removeNullPayloadMessages)
public CompactingConcurrentMapMessageStore(boolean removeNullPayloadMessages,
java.util.concurrent.ConcurrentMap<java.lang.String,java.io.Serializable> messageMap)
public void add(Message<java.lang.String> message)
add in interface MessageStorepublic ChannelPosition getLatestChannelPosition()
MessageStoreChannelPosition of the MessageStore.
The position is calculated by merging the
optional positions of the messages.
Messages without positions will not change the latest ChannelPosition. If no message contains
position information, the returned ChannelPosition is ChannelPosition.fromHorizon()
getLatestChannelPosition in interface MessageStorepublic java.util.stream.Stream<Message<java.lang.String>> stream()
MessageStoremessages contained in the MessageStore.
The stream will maintain the insertion order of the messages.
stream in interface MessageStorepublic int size()
MessageStoresize in interface MessageStore