Interface MessageStore
- All Known Implementing Classes:
AbstractKeyValueMessageStore
,ConfigurableMongoDbMessageStore
,HazelcastMessageStore
,JdbcMessageStore
,MongoDbMessageStore
,RedisMessageStore
,SimpleMessageStore
public interface MessageStore
Strategy interface for storing and retrieving messages.
- Since:
- 2.0
- Author:
- Mark Fisher, Iwein Fuld, Dave Syer, Artem Bilan
-
Method Summary
Modifier and TypeMethodDescription<T> Message<T>
addMessage
(Message<T> message) Put the provided Message into the MessageStore.Message<?>
getMessage
(UUID id) long
Optional attribute giving the number of messages in the store.Message<?>
removeMessage
(UUID id) Remove the Message with the given id from the MessageStore, if present, and return it.
-
Method Details
-
getMessage
- Parameters:
id
- The message identifier.- Returns:
- The Message with the given id, or null if no Message with that id exists in the MessageStore.
-
getMessageMetadata
- Parameters:
id
- The message identifier.- Returns:
- The MessageMetadata with the given id, or null if no Message with that id exists in the MessageStore or the message has no metadata (legacy message from an earlier version).
- Since:
- 5.0
-
addMessage
Put the provided Message into the MessageStore. The store may need to mutate the message internally, and if it does then the return value can be different than the input. The id of the return value will be used as an index so that thegetMessage(UUID)
andremoveMessage(UUID)
behave properly. Since messages are immutable, putting the same message more than once is a no-op.- Type Parameters:
T
- The payload type.- Parameters:
message
- The message.- Returns:
- The message that was stored.
-
removeMessage
Remove the Message with the given id from the MessageStore, if present, and return it. If no Message with that id is present in the store, this will returnnull
. If this method is implemented on aMessageGroupStore
, the message is removed from the store only if no groups holding this message.- Parameters:
id
- the message identifier.- Returns:
- the message (if any).
-
getMessageCount
Optional attribute giving the number of messages in the store. Implementations may decline to respond by throwing an exception.- Returns:
- The number of messages.
- Throws:
UnsupportedOperationException
- if not implemented
-