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.
|
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.
|
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 a deletion on a single message 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, setApplicationContext
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getMessage
messageGroupSize, removeMessageGroup
public 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)
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<?> removeMessage(UUID id)
MessageStore
removeMessage
in interface MessageStore
id
- THe message identifier.public long getMessageCount()
MessageStore
getMessageCount
in interface MessageStore
public MessageGroup getMessageGroup(Object groupId)
BasicMessageGroupStore
BasicMessageGroupStore.addMessageToGroup(Object, Message)
with this group id.getMessageGroup
in interface BasicMessageGroupStore
groupId
- The group identifier.public MessageGroup addMessageToGroup(Object groupId, Message<?> message)
BasicMessageGroupStore
addMessageToGroup
in interface BasicMessageGroupStore
groupId
- The group id to store the message under.message
- A message.public MessageGroup removeMessageFromGroup(Object groupId, Message<?> messageToRemove)
MessageGroupStore
removeMessageFromGroup
in interface MessageGroupStore
groupId
- The groupId for the group containing the message.messageToRemove
- The message to be removed.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 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 Iterator<MessageGroup> iterator()
iterator
in interface Iterable<MessageGroup>
iterator
in interface MessageGroupStore
MessageGroup
s.public void registerMessageGroupExpiryCallback(MessageGroupStore.MessageGroupCallback callback)
MessageGroupStore
MessageGroupStore.expireMessageGroups(long)
.registerMessageGroupExpiryCallback
in interface MessageGroupStore
callback
- A callback to execute when a message group is cleaned up.public int expireMessageGroups(long timeout)
MessageGroupStore
expireMessageGroups
in interface MessageGroupStore
timeout
- the timeout threshold to useMessageGroupStore.registerMessageGroupExpiryCallback(MessageGroupCallback)
@ManagedAttribute public int getMessageCountForAllMessageGroups()
MessageGroupStore
getMessageCountForAllMessageGroups
in interface MessageGroupStore
@ManagedAttribute public int getMessageGroupCount()
MessageGroupStore
getMessageGroupCount
in interface MessageGroupStore