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> Message<T> |
addMessage(Message<T> message)
Put the provided Message into the MessageStore.
|
void |
addMessagesToGroup(Object groupId,
Message<?>... messages)
Store messages with an association to a group id.
|
void |
clearMessageGroup(Object groupId) |
void |
completeGroup(Object groupId)
Completes this MessageGroup.
|
protected MessageGroup |
copy(MessageGroup group)
Used by expireMessageGroups.
|
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. |
MessageMetadata |
getMessageMetadata(UUID id)
|
Collection<Message<?>> |
getMessagesForGroup(Object groupId)
Retrieve messages for the provided 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.
|
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 |
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, waitaddMessageToGroupforEach, spliteratorpublic 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> 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 MessageMetadata getMessageMetadata(UUID id)
MessageStoregetMessageMetadata in interface MessageStoreid - 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 void addMessagesToGroup(Object groupId, Message<?>... messages)
MessageGroupStoreaddMessagesToGroup in interface MessageGroupStoregroupId - The group id to store messages under.messages - The messages to add.public void removeMessageGroup(Object groupId)
BasicMessageGroupStoreremoveMessageGroup in interface BasicMessageGroupStoregroupId - The id of the group to remove.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 MessageGroupStoregroupId - The group identifier.Message.public Collection<Message<?>> getMessagesForGroup(Object groupId)
MessageGroupStoregetMessagesForGroup in interface MessageGroupStoregroupId - The group id to retrieve messages for.public void clearMessageGroup(Object groupId)