public interface MessageStore
extends java.lang.AutoCloseable
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.
| Modifier and Type | Method and Description |
|---|---|
void |
add(MessageStoreEntry entry)
Appends the specified element to the end of this list (optional
operation).
|
default void |
close() |
java.util.Set<java.lang.String> |
getChannelNames()
Returns a set containing the channel names of the messages contained in the
MessageStore |
com.google.common.collect.ImmutableSet<Index> |
getIndexes() |
default ChannelPosition |
getLatestChannelPosition()
Deprecated.
|
ChannelPosition |
getLatestChannelPosition(java.lang.String channelName)
Returns the latest
ChannelPosition of the given channel, derived from the messages contained in this
MessageStore. |
default boolean |
isCompacting() |
default long |
size()
Returns the number of messages contained in the MessageStore.
|
java.util.stream.Stream<MessageStoreEntry> |
stream()
Returns a Stream of all entries contained in the MessageStore.
|
java.util.stream.Stream<MessageStoreEntry> |
stream(Index index,
java.lang.String value)
Returns a Stream of all entries contained in the MessageStore that have are matching the given Index value
(optional operation).
|
java.util.Set<java.lang.String> getChannelNames()
MessageStorecom.google.common.collect.ImmutableSet<Index> getIndexes()
ChannelPosition getLatestChannelPosition(java.lang.String channelName)
ChannelPosition of the given channel, derived from the messages contained in this
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()
channelName - the name of the channel@Deprecated default ChannelPosition getLatestChannelPosition()
java.util.stream.Stream<MessageStoreEntry> stream()
The stream will maintain the insertion order of the entries.
@Beta java.util.stream.Stream<MessageStoreEntry> stream(Index index, java.lang.String value)
The stream will maintain the insertion order of the entries.
index - the Indexvalue - the value identifying the requested messages in the specified indexjava.lang.UnsupportedOperationException - if the stream(Index,String) operation
is not supported by this storevoid add(@Nonnull
MessageStoreEntry entry)
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.
entry - element to be appended to this message storejava.lang.UnsupportedOperationException - if the add operation
is not supported by this storejava.lang.NullPointerException - if the specified element is nulljava.lang.IllegalArgumentException - if some property of this element
prevents it from being added to this listdefault long size()
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.
default void close()
close in interface java.lang.AutoCloseabledefault boolean isCompacting()