public class SimpleMessageStore extends AbstractMessageGroupStore implements MessageStore, ChannelMessageStore
MessageStore
and MessageGroupStore
.
Enforces a maximum capacity for the store.MessageGroupStore.MessageGroupCallback
logger
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, setTimeoutOnIdle
getRemoveBatchSize, setMessageGroupFactory, setRemoveBatchSize
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addMessageToGroup
forEach, spliterator
public 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)
AbstractMessageGroupStore
BasicMessageGroupStore.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 AbstractMessageGroupStore
lazyLoadMessageGroups
- the boolean
flag to use.@ManagedAttribute public long getMessageCount()
MessageStore
getMessageCount
in interface MessageStore
public <T> Message<T> addMessage(Message<T> message)
MessageStore
MessageStore.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 MessageStore
T
- The payload type.message
- The message.public Message<?> getMessage(UUID key)
getMessage
in interface MessageStore
key
- The message identifier.public MessageMetadata getMessageMetadata(UUID id)
MessageStore
getMessageMetadata
in interface MessageStore
id
- The message identifier.public Message<?> removeMessage(UUID key)
MessageStore
removeMessage
in interface MessageStore
key
- THe message identifier.public MessageGroup getMessageGroup(Object groupId)
BasicMessageGroupStore
BasicMessageGroupStore.addMessageToGroup(Object, Message)
with this group id.getMessageGroup
in interface BasicMessageGroupStore
groupId
- The group identifier.protected MessageGroup copy(MessageGroup group)
AbstractMessageGroupStore
copy
in class AbstractMessageGroupStore
group
- The group.public void addMessagesToGroup(Object groupId, Message<?>... messages)
MessageGroupStore
addMessagesToGroup
in interface MessageGroupStore
groupId
- The group id to store messages under.messages
- The messages to add.public void removeMessageGroup(Object groupId)
BasicMessageGroupStore
removeMessageGroup
in interface BasicMessageGroupStore
groupId
- The id of the group to remove.public void removeMessagesFromGroup(Object groupId, Collection<Message<?>> messages)
MessageGroupStore
removeMessagesFromGroup
in interface MessageGroupStore
groupId
- 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 MessageGroupStore
MessageGroup
s.public void setLastReleasedSequenceNumberForGroup(Object groupId, int sequenceNumber)
MessageGroupStore
setLastReleasedSequenceNumberForGroup
in interface MessageGroupStore
groupId
- The group identifier.sequenceNumber
- The sequence number.public void completeGroup(Object groupId)
MessageGroupStore
completeGroup
in interface MessageGroupStore
groupId
- The group identifier.public Message<?> pollMessageFromGroup(Object groupId)
BasicMessageGroupStore
MessageGroup
(in FIFO style if supported by the implementation)
while also removing the polled Message
pollMessageFromGroup
in interface BasicMessageGroupStore
groupId
- The group identifier.public int messageGroupSize(Object groupId)
BasicMessageGroupStore
messageGroupSize
in interface BasicMessageGroupStore
groupId
- The group identifier.public MessageGroupMetadata getGroupMetadata(Object groupId)
MessageGroupStore
getGroupMetadata
in interface MessageGroupStore
getGroupMetadata
in class AbstractMessageGroupStore
groupId
- The group id.public Message<?> getOneMessageFromGroup(Object groupId)
MessageGroupStore
Message
from MessageGroup
.getOneMessageFromGroup
in interface MessageGroupStore
groupId
- The group identifier.Message
.public Collection<Message<?>> getMessagesForGroup(Object groupId)
MessageGroupStore
getMessagesForGroup
in interface MessageGroupStore
groupId
- The group id to retrieve messages for.public void clearMessageGroup(Object groupId)