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)
|
| Modifier and Type | Method and Description |
|---|---|
<T> Message<T> |
addMessage(Message<T> message)
Put the provided Message into the MessageStore.
|
MessageGroup |
addMessageToGroup(Object groupId,
Message<?> message)
Store a message with an association to a group id.
|
void |
completeGroup(Object groupId)
Completes this MessageGroup.
|
protected MessageGroup |
copy(MessageGroup group)
Used by expireMessageGroups.
|
static SimpleMessageStore |
fastMessageStore(int capacity)
Deprecated.
in 4.1 - copyOnGet is now false by default.
|
MessageGroupMetadata |
getGroupMetadata(Object groupId)
Obtain the group metadata without fetching any messages; must supply all other
group properties; may include the id of the first message.
|
Message<?> |
getMessage(UUID key) |
long |
getMessageCount()
Optional attribute giving the number of messages in the store.
|
MessageGroup |
getMessageGroup(Object groupId)
Return all Messages currently in the MessageStore that were stored using
BasicMessageGroupStore.addMessageToGroup(Object, Message) with this group id. |
Message<?> |
getOneMessageFromGroup(Object groupId)
Return the one
Message from MessageGroup. |
Iterator<MessageGroup> |
iterator() |
int |
messageGroupSize(Object groupId)
Returns the size of this MessageGroup.
|
Message<?> |
pollMessageFromGroup(Object groupId)
Polls Message from this
MessageGroup (in FIFO style if supported by the implementation)
while also removing the polled Message |
Message<?> |
removeMessage(UUID key)
Remove the Message with the given id from the MessageStore, if present, and return it.
|
MessageGroup |
removeMessageFromGroup(Object groupId,
Message<?> messageToRemove)
Persist the deletion of a single message from the group.
|
void |
removeMessageGroup(Object groupId)
Remove the message group with this id.
|
void |
removeMessagesFromGroup(Object groupId,
Collection<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(Object groupId,
int sequenceNumber)
Allows you to set the sequence number of the last released Message.
|
void |
setLockRegistry(LockRegistry lockRegistry) |
expireMessageGroups, getMessageBuilderFactory, getMessageCountForAllMessageGroups, getMessageGroupCount, isTimeoutOnIdle, registerMessageGroupExpiryCallback, removeMessagesFromGroup, setBeanFactory, setExpiryCallbacks, setTimeoutOnIdlegetRemoveBatchSize, setRemoveBatchSizeclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEach, spliteratorpublic SimpleMessageStore(int individualCapacity,
int groupCapacity)
addMessage(Message) and to those stored via 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,
LockRegistry lockRegistry)
SimpleMessageStore(int, int).
Also allows the provision of a custom LockRegistry
rather than using the default.individualCapacity - The message capacity.groupCapacity - The capacity of each group.lockRegistry - The lock registry.public SimpleMessageStore(int capacity)
capacity - The capacity.public SimpleMessageStore()
@Deprecated public static SimpleMessageStore fastMessageStore(int capacity)
getMessageGroup(Object).capacity - the capacity (0 for unlimited).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)
@ManagedAttribute public long getMessageCount()
MessageStoregetMessageCount in interface MessageStorepublic <T> Message<T> addMessage(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 Message<?> getMessage(UUID key)
getMessage in interface MessageStorekey - The message identifier.public Message<?> removeMessage(UUID key)
MessageStoreremoveMessage in interface MessageStorekey - THe message identifier.public MessageGroup getMessageGroup(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 MessageGroup addMessageToGroup(Object groupId, Message<?> message)
BasicMessageGroupStoreaddMessageToGroup in interface BasicMessageGroupStoregroupId - The group id to store the message under.message - A message.public void removeMessageGroup(Object groupId)
BasicMessageGroupStoreremoveMessageGroup in interface BasicMessageGroupStoregroupId - The id of the group to remove.public MessageGroup removeMessageFromGroup(Object groupId, Message<?> messageToRemove)
MessageGroupStoreremoveMessageFromGroup in interface MessageGroupStoregroupId - The groupId for the group containing the message.messageToRemove - The message to be removed.public void removeMessagesFromGroup(Object groupId, Collection<Message<?>> messages)
MessageGroupStoreremoveMessagesFromGroup in interface MessageGroupStoregroupId - The groupId for the group containing the message(s).messages - The messages to be removed.public Iterator<MessageGroup> iterator()
iterator in interface Iterable<MessageGroup>iterator in interface MessageGroupStoreMessageGroups.public void setLastReleasedSequenceNumberForGroup(Object groupId, int sequenceNumber)
MessageGroupStoresetLastReleasedSequenceNumberForGroup in interface MessageGroupStoregroupId - The group identifier.sequenceNumber - The sequence number.public void completeGroup(Object groupId)
MessageGroupStorecompleteGroup in interface MessageGroupStoregroupId - The group identifier.public Message<?> pollMessageFromGroup(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(Object groupId)
BasicMessageGroupStoremessageGroupSize in interface BasicMessageGroupStoregroupId - The group identifier.public MessageGroupMetadata getGroupMetadata(Object groupId)
MessageGroupStoregetGroupMetadata in interface MessageGroupStoregetGroupMetadata in class AbstractMessageGroupStoregroupId - The group id.public Message<?> getOneMessageFromGroup(Object groupId)
MessageGroupStoreMessage from MessageGroup.getOneMessageFromGroup in interface MessageGroupStoregetOneMessageFromGroup in class AbstractMessageGroupStoregroupId - The group identifier.Message.