public class RedisChannelMessageStore extends Object implements ChannelMessageStore, BeanNameAware, InitializingBean, BeanClassLoaderAware
ChannelMessageStore
that uses a list to back a QueueChannel.
Requires setBeanName(String)
which is used as part of the key.
Constructor and Description |
---|
RedisChannelMessageStore(RedisConnectionFactory connectionFactory)
Construct a message store that uses Java Serialization for messages.
|
Modifier and Type | Method and Description |
---|---|
MessageGroup |
addMessageToGroup(Object groupId,
Message<?> message)
Store a message with an association to a group id.
|
void |
afterPropertiesSet() |
protected String |
getBeanName() |
int |
getMessageCountForAllMessageGroups() |
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() |
protected MessageGroupFactory |
getMessageGroupFactory() |
protected RedisTemplate<Object,Message<?>> |
getRedisTemplate() |
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 |
void |
removeMessageGroup(Object groupId)
Remove the message group with this id.
|
void |
setBeanClassLoader(ClassLoader classLoader) |
void |
setBeanName(String name) |
void |
setMessageGroupFactory(MessageGroupFactory messageGroupFactory)
Specify the
MessageGroupFactory to create MessageGroup object where
it is necessary. |
void |
setValueSerializer(RedisSerializer<?> valueSerializer)
Use a different serializer (default
JdkSerializationRedisSerializer for
the Message . |
public RedisChannelMessageStore(RedisConnectionFactory connectionFactory)
connectionFactory
- The redis connection factory.public void setBeanClassLoader(ClassLoader classLoader)
setBeanClassLoader
in interface BeanClassLoaderAware
public void setValueSerializer(RedisSerializer<?> valueSerializer)
JdkSerializationRedisSerializer
for
the Message
.valueSerializer
- The value serializer.public void setMessageGroupFactory(MessageGroupFactory messageGroupFactory)
MessageGroupFactory
to create MessageGroup
object where
it is necessary.
Defaults to SimpleMessageGroupFactory
.messageGroupFactory
- the MessageGroupFactory
to use.protected MessageGroupFactory getMessageGroupFactory()
public void setBeanName(String name)
setBeanName
in interface BeanNameAware
protected String getBeanName()
protected RedisTemplate<Object,Message<?>> getRedisTemplate()
public void afterPropertiesSet()
afterPropertiesSet
in interface InitializingBean
@ManagedAttribute public int messageGroupSize(Object groupId)
BasicMessageGroupStore
messageGroupSize
in interface BasicMessageGroupStore
groupId
- The group identifier.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 void removeMessageGroup(Object groupId)
BasicMessageGroupStore
removeMessageGroup
in interface BasicMessageGroupStore
groupId
- The id of the group to remove.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.@ManagedAttribute public int getMessageCountForAllMessageGroups()
@ManagedAttribute public int getMessageGroupCount()