Interface MessageStore
- All Superinterfaces:
AutoCloseable, HasMessageStore, Monitored<List<SerializedMessage>>
- All Known Implementing Classes:
CollectionMessageStore, InMemoryEventStore, InMemoryMessageStore, InMemoryScheduleStore, TestServerScheduleStore
public interface MessageStore
extends AutoCloseable, Monitored<List<SerializedMessage>>, HasMessageStore
A low-level store for serialized messages.
This interface defines an append-only log used to store SerializedMessage instances, typically representing
commands, events, queries, or other domain messages. It supports batched retrieval and allows integration with
in-memory or persistent message tracking implementations.
The MessageStore plays a central role in Fluxzero's tracking and message handling infrastructure.
In testing, in-memory implementations of MessageStore are used to simulate Fluxzero Runtime behavior.
This interface is also Monitored, allowing hooks to observe message publication, and extends
HasMessageStore so it can expose itself as a reusable component.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault CompletableFuture<Void> append(SerializedMessage... messages) Appends the given messages to the store.append(List<SerializedMessage> messages) Appends a list of messages to the store.default voidclose()Default no-op close method.default List<SerializedMessage> Retrieves a batch of messages starting from the givenlastIndex(exclusive).Retrieves a batch of messages starting from the givenminIndex.default MessageStoreReturns the current instance as theMessageStore.voidsetRetentionTime(Duration retentionPeriod) Sets the retention period for messages.default <T extends MessageStore>
TAttempts to unwrap the current instance to a concrete implementation or extension ofMessageStore.Methods inherited from interface Monitored
registerMonitor
-
Method Details
-
append
Appends the given messages to the store.- Parameters:
messages- messages to append- Returns:
- a
CompletableFuturethat completes when the messages have been successfully appended
-
append
Appends a list of messages to the store.- Parameters:
messages- messages to append- Returns:
- a
CompletableFuturethat completes when the messages have been successfully appended
-
getBatch
Retrieves a batch of messages starting from the givenlastIndex(exclusive).- Parameters:
lastIndex- minimum message index to start from (exclusive)maxSize- maximum number of messages to retrieve- Returns:
- a list of
SerializedMessageinstances
-
getBatch
Retrieves a batch of messages starting from the givenminIndex.- Parameters:
minIndex- minimum message index to start frommaxSize- maximum number of messages to retrieveinclusive- whether to include the message atminIndex- Returns:
- a list of
SerializedMessageinstances
-
setRetentionTime
Sets the retention period for messages. Messages older than this duration may be removed depending on the implementation.- Parameters:
retentionPeriod- duration to retain messages
-
unwrap
Attempts to unwrap the current instance to a concrete implementation or extension ofMessageStore.- Type Parameters:
T- the target type- Parameters:
type- the desired type to unwrap to- Returns:
- the unwrapped instance
- Throws:
UnsupportedOperationException- if the current instance cannot be unwrapped to the given type
-
close
default void close()Default no-op close method. Override if resources need cleanup.- Specified by:
closein interfaceAutoCloseable
-
getMessageStore
Returns the current instance as theMessageStore.- Specified by:
getMessageStorein interfaceHasMessageStore
-