Skip to main content
Version: Next

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 null for all history, 0 for none (real-time only), or N > 0 for the last N messages.


realtimeOverflow

  • type: PubSubSubscribeOptions.RealtimeOverflow

  • defaultValue: QUEUE

  • Policy for live messages that arrive faster than they can be delivered.

ValueBehaviour
QUEUEBuffer live messages and deliver them paced — lossless up to maxQueue. On overflow the oldest messages are dropped and onMessageDrop() reports the count.
DROPShed 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. Pass null to let the server decide.

  • The server clamps this value to its own maximum.

note

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 null or 0 for unlimited, or N > 0 to cap N messages per window (approximately 2 × N messages/second).


Example

val options = PubSubSubscribeOptions()
options.oldMessageLimit = 100
options.realtimeOverflow = PubSubSubscribeOptions.RealtimeOverflow.QUEUE
options.maxQueue = 70

meeting!!.pubSub.subscribe("CHAT", pubSubMessageListener, options)

Got a Question? Ask us on discord