@SPI public interface InboxStorage extends Storage<io.spine.server.delivery.InboxMessageId,io.spine.server.delivery.InboxMessage,InboxReadRequest>
Inbox
messages.
The records a storage of this type are spreads across shards identified by a shard index.
Typically, the storage instance is specific to the
server environment and is used across
BoundedContext
s to store the delivered messages.
Modifier and Type | Method and Description |
---|---|
java.util.Optional<io.spine.server.delivery.InboxMessage> |
newestMessageToDeliver(io.spine.server.delivery.ShardIndex index)
Finds the newest message to deliver
in the given shard.
|
Page<io.spine.server.delivery.InboxMessage> |
readAll(io.spine.server.delivery.ShardIndex index,
int pageSize)
Reads the contents of the storage by the given shard index and returns the first page
of the results.
|
void |
removeAll(java.lang.Iterable<io.spine.server.delivery.InboxMessage> messages)
Removes the passed messages from the storage.
|
void |
write(io.spine.server.delivery.InboxMessage message)
Writes a message to the storage.
|
void |
writeAll(java.lang.Iterable<io.spine.server.delivery.InboxMessage> messages)
Writes several messages to the storage.
|
Page<io.spine.server.delivery.InboxMessage> readAll(io.spine.server.delivery.ShardIndex index, int pageSize)
The older items go first.
index
- the shard index to return the results forpageSize
- the maximum number of the elements per pagejava.util.Optional<io.spine.server.delivery.InboxMessage> newestMessageToDeliver(io.spine.server.delivery.ShardIndex index)
index
- the shard index to look inOptional.empty()
if there are no messages to deliver
in the specified shardvoid write(io.spine.server.delivery.InboxMessage message)
message
- a message to writevoid writeAll(java.lang.Iterable<io.spine.server.delivery.InboxMessage> messages)
messages
- messages to writevoid removeAll(java.lang.Iterable<io.spine.server.delivery.InboxMessage> messages)
Does nothing for messages that aren't in the storage already.
messages
- the messages to remove