public class SimpleMessageStore extends AbstractMessageGroupStore implements MessageStore, ChannelMessageStore
MessageStore and MessageGroupStore.
Enforces a maximum capacity for the store.MessageGroupStore.MessageGroupCallbacklogger| Constructor and Description |
|---|
SimpleMessageStore()
Creates a SimpleMessageStore with unlimited capacity
|
SimpleMessageStore(int capacity)
Creates a SimpleMessageStore with the same capacity for individual and grouped messages.
|
SimpleMessageStore(int individualCapacity,
int groupCapacity)
Creates a SimpleMessageStore with a maximum size limited by the given capacity, or unlimited size if the given
capacity is less than 1.
|
SimpleMessageStore(int individualCapacity,
int groupCapacity,
LockRegistry lockRegistry)
Creates a SimpleMessageStore with a maximum size limited by the given capacity and LockRegistry
for the message group operations concurrency.
|
SimpleMessageStore(int individualCapacity,
int groupCapacity,
long upperBoundTimeout)
Creates a SimpleMessageStore with a maximum size limited by the given capacity and the timeout in millisecond
to wait for the empty slot in the store.
|
SimpleMessageStore(int individualCapacity,
int groupCapacity,
long upperBoundTimeout,
LockRegistry lockRegistry)
Creates a SimpleMessageStore with a maximum size limited by the given capacity,
the timeout in millisecond to wait for the empty slot in the store and LockRegistry
for the message group operations concurrency.
|
| Modifier and Type | Method and Description |
|---|---|
<T> org.springframework.messaging.Message<T> |
addMessage(org.springframework.messaging.Message<T> message)
Put the provided Message into the MessageStore.
|
void |
addMessagesToGroup(java.lang.Object groupId,
org.springframework.messaging.Message<?>... messages)
Store messages with an association to a group id.
|
void |
clearMessageGroup(java.lang.Object groupId) |
void |
completeGroup(java.lang.Object groupId)
Completes this MessageGroup.
|
protected MessageGroup |
copy(MessageGroup group)
Used by expireMessageGroups.
|
MessageGroupMetadata |
getGroupMetadata(java.lang.Object groupId)
Obtain the group metadata without fetching any messages; must supply all other
group properties; may include the id of the first message.
|
org.springframework.messaging.Message<?> |
getMessage(java.util.UUID key) |
long |
getMessageCount()
Optional attribute giving the number of messages in the store.
|
MessageGroup |
getMessageGroup(java.lang.Object groupId)
Return all Messages currently in the MessageStore that were stored using
BasicMessageGroupStore.addMessageToGroup(Object, Message) with this group id. |
MessageMetadata |
getMessageMetadata(java.util.UUID id)
|
java.util.Collection<org.springframework.messaging.Message<?>> |
getMessagesForGroup(java.lang.Object groupId)
Retrieve messages for the provided group id.
|
org.springframework.messaging.Message<?> |
getOneMessageFromGroup(java.lang.Object groupId)
Return the one
Message from MessageGroup. |
java.util.Iterator<MessageGroup> |
iterator() |
int |
messageGroupSize(java.lang.Object groupId)
Returns the size of this MessageGroup.
|
org.springframework.messaging.Message<?> |
pollMessageFromGroup(java.lang.Object groupId)
Polls Message from this
MessageGroup (in FIFO style if supported by the implementation)
while also removing the polled Message |
org.springframework.messaging.Message<?> |
removeMessage(java.util.UUID key)
Remove the Message with the given id from the MessageStore, if present, and return it.
|
void |
removeMessageGroup(java.lang.Object groupId)
Remove the message group with this id.
|
void |
removeMessagesFromGroup(java.lang.Object groupId,
java.util.Collection<org.springframework.messaging.Message<?>> messages)
Persist the deletion of messages from the group.
|
void |
setCopyOnGet(boolean copyOnGet)
Set to false to disable copying the group in
getMessageGroup(Object). |
void |
setLastReleasedSequenceNumberForGroup(java.lang.Object groupId,
int sequenceNumber)
Allows you to set the sequence number of the last released Message.
|
void |
setLazyLoadMessageGroups(boolean lazyLoadMessageGroups)
Specify if the result of the
BasicMessageGroupStore.getMessageGroup(Object) should be wrapped
to the PersistentMessageGroup - a lazy-load proxy for messages in group
Defaults to true. |
void |
setLockRegistry(LockRegistry lockRegistry) |
addMessageToGroup, expireMessageGroups, getMessageCountForAllMessageGroups, getMessageGroupCount, getMessageGroupFactory, isTimeoutOnIdle, registerMessageGroupExpiryCallback, removeMessagesFromGroup, setExpiryCallbacks, setTimeoutOnIdlegetRemoveBatchSize, setMessageGroupFactory, setRemoveBatchSizeclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddMessageToGrouppublic SimpleMessageStore(int individualCapacity,
int groupCapacity)
addMessage(Message) and to those stored via AbstractMessageGroupStore.addMessageToGroup(Object, Message). In both cases
the capacity applies to the number of messages that can be stored, and once that limit is reached attempting to
store another will result in an exception.individualCapacity - The message capacity.groupCapacity - The capacity of each group.public SimpleMessageStore(int individualCapacity,
int groupCapacity,
long upperBoundTimeout)
individualCapacity - The message capacity.groupCapacity - The capacity of each group.upperBoundTimeout - The time to wait if the store is at max capacity.SimpleMessageStore(int, int)public SimpleMessageStore(int individualCapacity,
int groupCapacity,
LockRegistry lockRegistry)
individualCapacity - The message capacity.groupCapacity - The capacity of each group.lockRegistry - The lock registry.SimpleMessageStore(int, int, long, LockRegistry)public SimpleMessageStore(int individualCapacity,
int groupCapacity,
long upperBoundTimeout,
LockRegistry lockRegistry)
individualCapacity - The message capacity.groupCapacity - The capacity of each group.upperBoundTimeout - The time to wait if the store is at max capacitylockRegistry - The lock registry.public SimpleMessageStore(int capacity)
capacity - The capacity.public SimpleMessageStore()
public void setCopyOnGet(boolean copyOnGet)
getMessageGroup(Object).
Starting with 4.1, this is false by default.copyOnGet - True to copy, false to not.public void setLockRegistry(LockRegistry lockRegistry)
public void setLazyLoadMessageGroups(boolean lazyLoadMessageGroups)
AbstractMessageGroupStoreBasicMessageGroupStore.getMessageGroup(Object) should be wrapped
to the PersistentMessageGroup - a lazy-load proxy for messages in group
Defaults to true.
The target logic is based on the SimpleMessageGroupFactory.GroupType.PERSISTENT.
setLazyLoadMessageGroups in class AbstractMessageGroupStorelazyLoadMessageGroups - the boolean flag to use.@ManagedAttribute public long getMessageCount()
MessageStoregetMessageCount in interface MessageStorepublic <T> org.springframework.messaging.Message<T> addMessage(org.springframework.messaging.Message<T> message)
MessageStoreMessageStore.getMessage(UUID) and MessageStore.removeMessage(UUID) behave properly. Since messages are
immutable, putting the same message more than once is a no-op.addMessage in interface MessageStoreT - The payload type.message - The message.public org.springframework.messaging.Message<?> getMessage(java.util.UUID key)
getMessage in interface MessageStorekey - The message identifier.public MessageMetadata getMessageMetadata(java.util.UUID id)
MessageStoregetMessageMetadata in interface MessageStoreid - The message identifier.public org.springframework.messaging.Message<?> removeMessage(java.util.UUID key)
MessageStoreremoveMessage in interface MessageStorekey - THe message identifier.public MessageGroup getMessageGroup(java.lang.Object groupId)
BasicMessageGroupStoreBasicMessageGroupStore.addMessageToGroup(Object, Message) with this group id.getMessageGroup in interface BasicMessageGroupStoregroupId - The group identifier.protected MessageGroup copy(MessageGroup group)
AbstractMessageGroupStorecopy in class AbstractMessageGroupStoregroup - The group.public void addMessagesToGroup(java.lang.Object groupId,
org.springframework.messaging.Message<?>... messages)
MessageGroupStoreaddMessagesToGroup in interface MessageGroupStoregroupId - The group id to store messages under.messages - The messages to add.public void removeMessageGroup(java.lang.Object groupId)
BasicMessageGroupStoreremoveMessageGroup in interface BasicMessageGroupStoregroupId - The id of the group to remove.public void removeMessagesFromGroup(java.lang.Object groupId,
java.util.Collection<org.springframework.messaging.Message<?>> messages)
MessageGroupStoreremoveMessagesFromGroup in interface MessageGroupStoregroupId - The groupId for the group containing the message(s).messages - The messages to be removed.public java.util.Iterator<MessageGroup> iterator()
iterator in interface java.lang.Iterable<MessageGroup>iterator in interface MessageGroupStoreMessageGroups.public void setLastReleasedSequenceNumberForGroup(java.lang.Object groupId,
int sequenceNumber)
MessageGroupStoresetLastReleasedSequenceNumberForGroup in interface MessageGroupStoregroupId - The group identifier.sequenceNumber - The sequence number.public void completeGroup(java.lang.Object groupId)
MessageGroupStorecompleteGroup in interface MessageGroupStoregroupId - The group identifier.public org.springframework.messaging.Message<?> pollMessageFromGroup(java.lang.Object groupId)
BasicMessageGroupStoreMessageGroup (in FIFO style if supported by the implementation)
while also removing the polled MessagepollMessageFromGroup in interface BasicMessageGroupStoregroupId - The group identifier.public int messageGroupSize(java.lang.Object groupId)
BasicMessageGroupStoremessageGroupSize in interface BasicMessageGroupStoregroupId - The group identifier.public MessageGroupMetadata getGroupMetadata(java.lang.Object groupId)
MessageGroupStoregetGroupMetadata in interface MessageGroupStoregetGroupMetadata in class AbstractMessageGroupStoregroupId - The group id.public org.springframework.messaging.Message<?> getOneMessageFromGroup(java.lang.Object groupId)
MessageGroupStoreMessage from MessageGroup.getOneMessageFromGroup in interface MessageGroupStoregroupId - The group identifier.Message.public java.util.Collection<org.springframework.messaging.Message<?>> getMessagesForGroup(java.lang.Object groupId)
MessageGroupStoregetMessagesForGroup in interface MessageGroupStoregroupId - The group id to retrieve messages for.public void clearMessageGroup(java.lang.Object groupId)