-
public final class MessageBufferConfigConfiguration for buffering inbound
NewMessageEvents for specific channel types before they are dispatched to the sequential event-handling pipeline.High-traffic channel types (e.g. livestreams) can produce a flood of new-message events that arrive faster than they can be processed sequentially. This configuration applies a bounded buffer with a configurable overflow strategy (e.g. drop oldest) for
NewMessageEvents on the configured channel types only. Events for other channel types — and all non-NewMessageEventevents — continue to flow through the default unbuffered path withInt.MAX_VALUEcapacity, so signal-critical events such as reads, bans or member updates are never dropped.By default this is a no-op: no channel types are configured, so the buffered code path is not active and the SDK behaves exactly as if this configuration did not exist.
Event ordering caveat. When buffering is active,
NewMessageEvents for opted-in channel types flow through a separate buffer from all other events. As a consequence, the relative ordering between bufferedNewMessageEvents and non-buffered events (e.g.ReactionNewEvent,MessageUpdatedEvent) for the same channel is not guaranteed — a reaction added to message X may be processed before theNewMessageEventfor X. Because this configuration already tolerates dropping events on overflow, callers opting in are expected to tolerate this consistency relaxation as well.Example — drop the oldest pending
NewMessageEventformessagingchannels when more than 100 are queued:ChatClientConfig( messageLimitConfig = MessageLimitConfig( messageBufferConfig = MessageBufferConfig( channelTypes = setOf("messaging"), capacity = 100, overflow = MessageBufferOverflow.DROP_OLDEST, ), ), )
-
-
Field Summary
Fields Modifier and Type Field Description private final Set<String>channelTypesprivate final Integercapacityprivate final MessageBufferOverflowoverflow
-
Constructor Summary
Constructors Constructor Description MessageBufferConfig(Set<String> channelTypes, Integer capacity, MessageBufferOverflow overflow)
-
Method Summary
Modifier and Type Method Description final Set<String>getChannelTypes()final IntegergetCapacity()final MessageBufferOverflowgetOverflow()-
-
Constructor Detail
-
MessageBufferConfig
MessageBufferConfig(Set<String> channelTypes, Integer capacity, MessageBufferOverflow overflow)
- Parameters:
channelTypes- The set of channel types whoseNewMessageEvents should be routed through the bounded buffer.capacity- The maximum number ofNewMessageEvents that can be queued in the buffer while the consumer is busy.overflow- The strategy applied when the buffer is full:MessageBufferOverflow.DROP_OLDEST (default): the oldest queued event is evicted to make room for the new one. Useful for live channels where freshness matters more than completeness.
MessageBufferOverflow.DROP_LATEST: the newest event is discarded and the queued events are kept.
-
-
Method Detail
-
getChannelTypes
final Set<String> getChannelTypes()
-
getCapacity
final Integer getCapacity()
-
getOverflow
final MessageBufferOverflow getOverflow()
-
-
-
-