public class ConfigurableMongoDbMessageStore extends AbstractConfigurableMongoDbMessageStore implements MessageStore
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.
|
void |
addMessagesToGroup(Object groupId,
Message<?>... messages)
Store messages with an association to a group id.
|
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.
|
Collection<Message<?>> |
getMessagesForGroup(Object groupId)
Retrieve messages for the provided group id.
|
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)
Deprecated.
|
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, setApplicationContextcopy, getMessageBuilderFactory, getMessageGroupFactory, setBeanFactory, setLazyLoadMessageGroupsgetRemoveBatchSize, setMessageGroupFactory, setRemoveBatchSizeclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetMessageforEach, 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).setExpiryCallbacks in class AbstractMessageGroupStoreexpiryCallbacks - the expiry callbacks to addpublic boolean isTimeoutOnIdle()
isTimeoutOnIdle in class AbstractMessageGroupStorepublic 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'.setTimeoutOnIdle in class AbstractMessageGroupStoretimeoutOnIdle - 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 BasicMessageGroupStoreaddMessageToGroup in class AbstractMessageGroupStoregroupId - The group id to store the message under.message - A message.public void addMessagesToGroup(Object groupId, Message<?>... messages)
MessageGroupStoreaddMessagesToGroup in interface MessageGroupStoreaddMessagesToGroup in class AbstractConfigurableMongoDbMessageStoregroupId - The group id to store messages under.messages - The messages to add.@Deprecated public MessageGroup removeMessageFromGroup(Object groupId, Message<?> messageToRemove)
MessageGroupStoreremoveMessageFromGroup in interface MessageGroupStoreremoveMessageFromGroup in class AbstractConfigurableMongoDbMessageStoregroupId - 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 MessageGroupStoreremoveMessagesFromGroup in class AbstractConfigurableMongoDbMessageStoregroupId - 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 MessageGroupStoreremoveMessagesFromGroup in class AbstractMessageGroupStoregroupId - 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 MessageGroupStoresetLastReleasedSequenceNumberForGroup in class AbstractConfigurableMongoDbMessageStoregroupId - The group identifier.sequenceNumber - The sequence number.public void completeGroup(Object groupId)
MessageGroupStorecompleteGroup in interface MessageGroupStorecompleteGroup in class AbstractConfigurableMongoDbMessageStoregroupId - The group identifier.public Iterator<MessageGroup> iterator()
iterator in interface Iterable<MessageGroup>iterator in interface MessageGroupStoreiterator in class AbstractConfigurableMongoDbMessageStoreMessageGroups.public void registerMessageGroupExpiryCallback(MessageGroupStore.MessageGroupCallback callback)
MessageGroupStoreMessageGroupStore.expireMessageGroups(long).registerMessageGroupExpiryCallback in interface MessageGroupStoreregisterMessageGroupExpiryCallback in class AbstractMessageGroupStorecallback - A callback to execute when a message group is cleaned up.@ManagedOperation public int expireMessageGroups(long timeout)
MessageGroupStoreexpireMessageGroups in interface MessageGroupStoreexpireMessageGroups in class AbstractMessageGroupStoretimeout - the timeout threshold to useMessageGroupStore.registerMessageGroupExpiryCallback(MessageGroupCallback)@ManagedAttribute public int getMessageCountForAllMessageGroups()
MessageGroupStoregetMessageCountForAllMessageGroups in interface MessageGroupStoregetMessageCountForAllMessageGroups in class AbstractMessageGroupStore@ManagedAttribute public int getMessageGroupCount()
MessageGroupStoregetMessageGroupCount in interface MessageGroupStoregetMessageGroupCount in class AbstractMessageGroupStorepublic 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 AbstractConfigurableMongoDbMessageStoregroupId - The group identifier.Message.public Collection<Message<?>> getMessagesForGroup(Object groupId)
MessageGroupStoregetMessagesForGroup in interface MessageGroupStoregetMessagesForGroup in class AbstractConfigurableMongoDbMessageStoregroupId - The group id to retrieve messages for.