Interface MessageStore
- All Superinterfaces:
AutoCloseable
- All Known Subinterfaces:
SnapshotMessageStore
- All Known Implementing Classes:
DelegatingSnapshotMessageStore,OffHeapIndexingMessageStore,OnHeapCompactingMessageStore,OnHeapIndexingMessageStore,OnHeapRingBufferMessageStore
When using a Message Store, we can take advantage of the asynchronous nature of a messaging infrastructure. When we send a message to a channel, we send a duplicate of the message to a special channel to be collected by the Message Store.
This can be performed by the component itself or we can insert a Wire Tap into the channel. We can consider the secondary channel that carries a copy of the message as part of the Control Bus. Sending a second message in a 'fire-and-forget' mode will not slow down the flow of the main application messages. It does, however, increase network traffic. That's why we may not store the complete message, but just a few of fields that are required for later analysis, such as a message ID, or the channel on which the message was sent and a timestamp.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidadd(MessageStoreEntry entry) Appends the specified element to the end of this list (optional operation).default voidclose()Returns a set containing the channel names of the messages contained in theMessageStorecom.google.common.collect.ImmutableSet<Index>default ChannelPositionDeprecated.getLatestChannelPosition(String channelName) Returns the latestChannelPositionof the given channel, derived from the messages contained in thisMessageStore.default booleandefault longsize()Returns the number of messages contained in the MessageStore.stream()Returns a Stream of all entries contained in the MessageStore.Returns a Stream of all entries contained in the MessageStore that have are matching the given Index value (optional operation).
-
Method Details
-
getChannelNames
Returns a set containing the channel names of the messages contained in theMessageStore- Returns:
- set of channel names
-
getIndexes
com.google.common.collect.ImmutableSet<Index> getIndexes() -
getLatestChannelPosition
Returns the latestChannelPositionof the given channel, derived from the messages contained in thisMessageStore.The position is calculated by
mergingtheoptional positionsof the messages.Messages without positions will not change the latest ChannelPosition. If no message contains position information, the returned ChannelPosition is
ChannelPosition.fromHorizon()- Parameters:
channelName- the name of the channel- Returns:
- ChannelPosition
-
getLatestChannelPosition
Deprecated. -
stream
Stream<MessageStoreEntry> stream()Returns a Stream of all entries contained in the MessageStore.The stream will maintain the insertion order of the entries.
- Returns:
- Stream of entries
-
stream
Returns a Stream of all entries contained in the MessageStore that have are matching the given Index value (optional operation).The stream will maintain the insertion order of the entries.
- Parameters:
index- the Indexvalue- the value identifying the requested messages in the specified index- Returns:
- stream of message-store entries matching the index or emptyStream, if the index is not known, or if there are no entries
- Throws:
UnsupportedOperationException- if the 'stream(Index,String)' operation is not supported by this store
-
add
Appends the specified element to the end of this list (optional operation).MessageStores that support this operation may place limitations on what elements may be added to this list. In particular, some stores will refuse to add entries for more than a single
channel. MessageStore classes should clearly specify in their documentation any restrictions on what elements may be added.- Parameters:
entry- element to be appended to this message store- Throws:
UnsupportedOperationException- if the 'add' operation is not supported by this storeNullPointerException- if the specified element is nullIllegalArgumentException- if some property of this element prevents it from being added to this list
-
size
default long size()Returns the number of messages contained in the MessageStore.Primarily used for testing purposes. If the MessageStore can not implement this without major performance impacts (like, for example, having to download and parse huge files from S3), the method is not required to be implemented.
- Returns:
- number of messages
-
close
default void close()- Specified by:
closein interfaceAutoCloseable
-
isCompacting
default boolean isCompacting()
-