PubSubSubscribeOptions Class - Android
Configuration options for subscribing to a PubSub topic with batched delivery.
Passing these options to subscribe() opts the subscription into server-paced batching: historical messages stream in batches via onOldMessagesReceived(), live messages arrive in paced batches, and overflow under load is controlled by realtimeOverflow.
Properties
oldMessageLimit
-
type:
Integer -
defaultValue:
null -
Limits how many persisted (historical) messages are fetched on subscribe.
-
Pass
nullfor all history,0for none (real-time only), orN > 0for the last N messages.
realtimeOverflow
-
type:
PubSubSubscribeOptions.RealtimeOverflow -
defaultValue:
QUEUE -
Policy for live messages that arrive faster than they can be delivered.
| Value | Behaviour |
|---|---|
QUEUE | Buffer live messages and deliver them paced — lossless up to maxQueue. On overflow the oldest messages are dropped and onMessageDrop() reports the count. |
DROP | Shed load — the newest messages of each delivery window survive, the rest are dropped silently. onMessageDrop() never fires. |
maxQueue
-
type:
Integer -
defaultValue:
null -
Live-message buffer ceiling under
RealtimeOverflow.QUEUE. Must be>= 1. Passnullto let the server decide. -
The server clamps this value to its own maximum.
maxQueue is only valid with RealtimeOverflow.QUEUE. Combining it with RealtimeOverflow.DROP makes subscribe() throw an IllegalArgumentException.
newMessageLimit
-
type:
Integer -
defaultValue:
null -
Caps how many new (live) messages this subscriber accepts per server batching window (500 ms). Extra messages in a window are skipped silently.
-
Pass
nullor0for unlimited, orN > 0to cap N messages per window (approximately2 × Nmessages/second).
Example
- Kotlin
- Java
val options = PubSubSubscribeOptions()
options.oldMessageLimit = 100
options.realtimeOverflow = PubSubSubscribeOptions.RealtimeOverflow.QUEUE
options.maxQueue = 70
meeting!!.pubSub.subscribe("CHAT", pubSubMessageListener, options)
PubSubSubscribeOptions options = new PubSubSubscribeOptions();
options.setOldMessageLimit(100);
options.setRealtimeOverflow(PubSubSubscribeOptions.RealtimeOverflow.QUEUE);
options.setMaxQueue(70);
meeting.pubSub.subscribe("CHAT", pubSubMessageListener, options);
Got a Question? Ask us on discord

