public class MongoDbMessageStore extends AbstractMessageGroupStore implements MessageStore, BeanClassLoaderAware, ApplicationContextAware, InitializingBean
MessageStore and MessageGroupStore
strategies that relies upon MongoDB for persistence.MessageGroupStore.MessageGroupCallback| Modifier and Type | Field and Description |
|---|---|
static String |
CREATED_DATE_KEY
The name of the message header that stores a timestamp for the time the message was inserted.
|
static String |
SAVED_KEY
The name of the message header that stores a flag to indicate that the message has been saved.
|
static String |
SEQUENCE_NAME |
logger| Constructor and Description |
|---|
MongoDbMessageStore(MongoDbFactory mongoDbFactory)
Create a MongoDbMessageStore using the provided
MongoDbFactory.and the default collection name. |
MongoDbMessageStore(MongoDbFactory mongoDbFactory,
String collectionName)
Create a MongoDbMessageStore using the provided
MongoDbFactory and collection name. |
| 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 |
afterPropertiesSet() |
void |
completeGroup(Object groupId)
Completes this MessageGroup.
|
Message<?> |
getMessage(UUID id) |
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. |
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 id)
Remove the Message with the given id from the MessageStore, if present, and return it.
|
MessageGroup |
removeMessageFromGroup(Object groupId,
Message<?> messageToRemove)
Deprecated.
|
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 |
setApplicationContext(ApplicationContext applicationContext) |
void |
setBeanClassLoader(ClassLoader classLoader) |
void |
setLastReleasedSequenceNumberForGroup(Object groupId,
int sequenceNumber)
Allows you to set the sequence number of the last released Message.
|
addMessageToGroup, copy, expireMessageGroups, getGroupMetadata, getMessageBuilderFactory, getMessageGroupFactory, isTimeoutOnIdle, registerMessageGroupExpiryCallback, removeMessagesFromGroup, setBeanFactory, setExpiryCallbacks, setLazyLoadMessageGroups, setTimeoutOnIdlegetRemoveBatchSize, setMessageGroupFactory, setRemoveBatchSizeclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEach, spliteratorpublic static final String SEQUENCE_NAME
public static final String SAVED_KEY
public static final String CREATED_DATE_KEY
public MongoDbMessageStore(MongoDbFactory mongoDbFactory)
MongoDbFactory.and the default collection name.mongoDbFactory - The mongodb factory.public MongoDbMessageStore(MongoDbFactory mongoDbFactory, String collectionName)
MongoDbFactory and collection name.mongoDbFactory - The mongodb factory.collectionName - The collection name.public void setBeanClassLoader(ClassLoader classLoader)
setBeanClassLoader in interface BeanClassLoaderAwarepublic void setApplicationContext(ApplicationContext applicationContext) throws BeansException
setApplicationContext in interface ApplicationContextAwareBeansExceptionpublic void afterPropertiesSet()
throws Exception
afterPropertiesSet in interface InitializingBeanExceptionpublic <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 id)
getMessage in interface MessageStoreid - The message identifier.@ManagedAttribute public long getMessageCount()
MessageStoregetMessageCount in interface MessageStorepublic Message<?> removeMessage(UUID id)
MessageStoreremoveMessage in interface MessageStoreid - THe message identifier.public MessageGroup getMessageGroup(Object groupId)
BasicMessageGroupStoreBasicMessageGroupStore.addMessageToGroup(Object, Message) with this group id.getMessageGroup in interface BasicMessageGroupStoregroupId - The group identifier.public void addMessagesToGroup(Object groupId, Message<?>... messages)
MessageGroupStoreaddMessagesToGroup in interface MessageGroupStoregroupId - The group id to store messages under.messages - The messages to add.@Deprecated 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 removeMessageGroup(Object groupId)
BasicMessageGroupStoreremoveMessageGroup in interface BasicMessageGroupStoregroupId - The id of the group to remove.public Iterator<MessageGroup> iterator()
iterator in interface Iterable<MessageGroup>iterator in interface MessageGroupStoreMessageGroups.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 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<?> 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.@ManagedAttribute public int getMessageCountForAllMessageGroups()
MessageGroupStoregetMessageCountForAllMessageGroups in interface MessageGroupStoregetMessageCountForAllMessageGroups in class AbstractMessageGroupStore@ManagedAttribute public int getMessageGroupCount()
MessageGroupStoregetMessageGroupCount in interface MessageGroupStoregetMessageGroupCount in class AbstractMessageGroupStore