public class ConfigurableMongoDbMessageStore extends AbstractConfigurableMongoDbMessageStore implements MessageStore, MessageGroupStore, Iterable<MessageGroup>
MessageStore and MessageGroupStore which allows the user to
configure the instance of MongoTemplate. The mechanism of storing the messages/group of messages
in the store is and is different from MongoDbMessageStore. Since the store uses serialization of the
messages by default, all the headers, and the payload of the Message must implement Serializable
interfaceMessageGroupStore.MessageGroupCallback| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_COLLECTION_NAME |
applicationContext, collectionName, CREATED_DATE_KEY, logger, mappingMongoConverter, messageBuilderFactory, mongoDbFactory, mongoTemplate, SAVED_KEY, SEQUENCE_NAME| Constructor and Description |
|---|
ConfigurableMongoDbMessageStore(MongoDbFactory mongoDbFactory) |
ConfigurableMongoDbMessageStore(MongoDbFactory mongoDbFactory,
MappingMongoConverter mappingMongoConverter) |
ConfigurableMongoDbMessageStore(MongoDbFactory mongoDbFactory,
MappingMongoConverter mappingMongoConverter,
String collectionName) |
ConfigurableMongoDbMessageStore(MongoDbFactory mongoDbFactory,
String collectionName) |
ConfigurableMongoDbMessageStore(MongoTemplate mongoTemplate) |
ConfigurableMongoDbMessageStore(MongoTemplate mongoTemplate,
String collectionName) |
| 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.
|
int |
expireMessageGroups(long timeout)
Extract all expired groups (whose timestamp is older than the current time less the threshold provided) and call
each of the registered callbacks on them in turn.
|
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.
|
long |
getMessageCount()
Optional attribute giving the number of messages in the store.
|
int |
getMessageCountForAllMessageGroups()
Optional attribute giving the number of messages in the store over all groups.
|
MessageGroup |
getMessageGroup(Object groupId)
Return all Messages currently in the MessageStore that were stored using
BasicMessageGroupStore.addMessageToGroup(Object, Message) with this group id. |
int |
getMessageGroupCount()
Optional attribute giving the number of message groups.
|
Message<?> |
getOneMessageFromGroup(Object groupId)
Return the one
Message from MessageGroup. |
boolean |
isTimeoutOnIdle() |
Iterator<MessageGroup> |
iterator() |
Message<?> |
pollMessageFromGroup(Object groupId)
Polls Message from this
MessageGroup (in FIFO style if supported by the implementation)
while also removing the polled Message |
void |
registerMessageGroupExpiryCallback(MessageGroupStore.MessageGroupCallback callback)
Register a callback for when a message group is expired through
MessageGroupStore.expireMessageGroups(long). |
Message<?> |
removeMessage(UUID id)
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 |
removeMessagesFromGroup(Object groupId,
Collection<Message<?>> messages)
Persist the deletion of messages from the group.
|
void |
removeMessagesFromGroup(Object groupId,
Message<?>... messages)
Persist the deletion of messages from the group.
|
void |
setExpiryCallbacks(Collection<MessageGroupStore.MessageGroupCallback> expiryCallbacks)
Convenient injection point for expiry callbacks in the message store.
|
void |
setLastReleasedSequenceNumberForGroup(Object groupId,
int sequenceNumber)
Allows you to set the sequence number of the last released Message.
|
void |
setTimeoutOnIdle(boolean timeoutOnIdle)
Allows you to override the rule for the timeout calculation.
|
addMessageDocument, afterPropertiesSet, getMessage, getNextId, groupIdQuery, messageGroupSize, removeMessageGroup, setApplicationContextgetRemoveBatchSize, setRemoveBatchSizeclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetMessagemessageGroupSize, removeMessageGroupforEach, spliteratorpublic static final String DEFAULT_COLLECTION_NAME
public ConfigurableMongoDbMessageStore(MongoTemplate mongoTemplate)
public ConfigurableMongoDbMessageStore(MongoTemplate mongoTemplate, String collectionName)
public ConfigurableMongoDbMessageStore(MongoDbFactory mongoDbFactory)
public ConfigurableMongoDbMessageStore(MongoDbFactory mongoDbFactory, MappingMongoConverter mappingMongoConverter)
public ConfigurableMongoDbMessageStore(MongoDbFactory mongoDbFactory, String collectionName)
public ConfigurableMongoDbMessageStore(MongoDbFactory mongoDbFactory, MappingMongoConverter mappingMongoConverter, String collectionName)
public void setExpiryCallbacks(Collection<MessageGroupStore.MessageGroupCallback> expiryCallbacks)
MessageGroupStore.registerMessageGroupExpiryCallback(MessageGroupCallback).expiryCallbacks - the expiry callbacks to addpublic boolean isTimeoutOnIdle()
public void setTimeoutOnIdle(boolean timeoutOnIdle)
MessageGroup was created. If you want the timeout to be based on the time
the MessageGroup was idling (e.g., inactive from the last update) invoke this method with 'true'.
Default is 'false'.timeoutOnIdle - The boolean.public <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<?> removeMessage(UUID id)
MessageStoreremoveMessage in interface MessageStoreid - THe message identifier.public long getMessageCount()
MessageStoregetMessageCount in interface MessageStorepublic MessageGroup getMessageGroup(Object groupId)
BasicMessageGroupStoreBasicMessageGroupStore.addMessageToGroup(Object, Message) with this group id.getMessageGroup in interface BasicMessageGroupStoregroupId - The group identifier.public MessageGroup addMessageToGroup(Object groupId, Message<?> message)
BasicMessageGroupStoreaddMessageToGroup in interface BasicMessageGroupStoregroupId - The group id to store the message under.message - A message.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 void removeMessagesFromGroup(Object groupId, Message<?>... messages)
MessageGroupStoreremoveMessagesFromGroup in interface MessageGroupStoregroupId - The groupId for the group containing the message(s).messages - The messages to be removed.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 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 Iterator<MessageGroup> iterator()
iterator in interface Iterable<MessageGroup>iterator in interface MessageGroupStoreMessageGroups.public void registerMessageGroupExpiryCallback(MessageGroupStore.MessageGroupCallback callback)
MessageGroupStoreMessageGroupStore.expireMessageGroups(long).registerMessageGroupExpiryCallback in interface MessageGroupStorecallback - A callback to execute when a message group is cleaned up.public int expireMessageGroups(long timeout)
MessageGroupStoreexpireMessageGroups in interface MessageGroupStoretimeout - the timeout threshold to useMessageGroupStore.registerMessageGroupExpiryCallback(MessageGroupCallback)@ManagedAttribute public int getMessageCountForAllMessageGroups()
MessageGroupStoregetMessageCountForAllMessageGroups in interface MessageGroupStore@ManagedAttribute public int getMessageGroupCount()
MessageGroupStoregetMessageGroupCount in interface MessageGroupStorepublic MessageGroupMetadata getGroupMetadata(Object groupId)
MessageGroupStoregetGroupMetadata in interface MessageGroupStoregroupId - The group id.public Message<?> getOneMessageFromGroup(Object groupId)
MessageGroupStoreMessage from MessageGroup.getOneMessageFromGroup in interface MessageGroupStoregroupId - The group identifier.Message.