-
public final class MessageLimitConfigConfiguration for message limits in channels.
This configuration allows you to control memory usage by limiting the number of messages kept in the in-memory state for different channel types. When a channel exceeds its configured message limit (plus a 30-message buffer to avoid frequent trimming), the SDK automatically removes the oldest messages from memory while keeping the most recent ones.
Message trimming behavior:
Only applies when not loading older messages (to avoid interfering with pagination)
Sorts messages by creation time and keeps the most recent ones
Sets
endOfOlderMessagestofalsewhen trimming occurs (indicating more messages exist)Messages are only removed from in-memory state, not from the local database
Use cases:
Limit memory usage in channels with extensive message history
Optimize performance in resource-constrained environments
Configure different limits for different channel types (e.g., smaller limits for group channels, larger for DMs)
Example configuration:
StatePluginConfig( messageLimitConfig = MessageLimitConfig( channelMessageLimits = setOf( ChannelMessageLimit(channelType = "messaging", baseLimit = 1000), ChannelMessageLimit(channelType = "livestream", baseLimit = 500) ) ) )
-
-
Field Summary
Fields Modifier and Type Field Description private final Set<ChannelMessageLimit>channelMessageLimitsprivate final MessageBufferConfigmessageBufferConfig
-
Constructor Summary
Constructors Constructor Description MessageLimitConfig(Set<ChannelMessageLimit> channelMessageLimits, MessageBufferConfig messageBufferConfig)
-
Method Summary
Modifier and Type Method Description final Set<ChannelMessageLimit>getChannelMessageLimits()final MessageBufferConfiggetMessageBufferConfig()-
-
Constructor Detail
-
MessageLimitConfig
MessageLimitConfig(Set<ChannelMessageLimit> channelMessageLimits, MessageBufferConfig messageBufferConfig)
- Parameters:
channelMessageLimits- A set of ChannelMessageLimit defining the maximum number of messages to keep in memory for different channel types.messageBufferConfig- Configuration for bounding the inboundNewMessageEventbuffer on selected channel types.
-
-
Method Detail
-
getChannelMessageLimits
final Set<ChannelMessageLimit> getChannelMessageLimits()
-
getMessageBufferConfig
final MessageBufferConfig getMessageBufferConfig()
-
-
-
-