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 |
|---|---|
default void |
close() |
ChannelPosition |
getLatestChannelPosition()
Returns the latest
ChannelPosition of the MessageStore. |
default 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. |
ChannelPosition getLatestChannelPosition()
ChannelPosition 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()
java.util.stream.Stream<Message<java.lang.String>> stream()
messages contained in the MessageStore.
The stream will maintain the insertion order of the messages.
default int 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.AutoCloseable