Package 

Class MessageLimitConfig


  • 
    public final class MessageLimitConfig
    
                        

    Configuration 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 endOfOlderMessages to false when 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)
            )
        )
    )