Consumer Groups
Consumer groups track read positions independently, enabling multiple consumers to process the same stream at their own pace.
-- Create consumer groups
CREATE CONSUMER GROUP analytics ON order_changes;
CREATE CONSUMER GROUP billing ON order_changes;
-- Commit offset for a specific partition
COMMIT OFFSET PARTITION 0 AT 42 ON order_changes CONSUMER GROUP analytics;
-- Batch commit all partitions
COMMIT OFFSETS ON order_changes CONSUMER GROUP analytics;
DROP CONSUMER GROUP analytics ON order_changes;
Stream Partitions
SHOW PARTITIONS ON <stream> lists every partition that holds events in the stream's buffer:
SHOW PARTITIONS ON order_changes;
| Column | Meaning |
partition_id | The partition the offsets belong to. |
earliest_offset | The oldest buffered event's offset. |
latest_offset | The newest buffered event's offset. |
event_count | The number of buffered events. |
SHOW PARTITIONS FOR <timeseries> is a different statement: it lists a timeseries collection's storage partitions (see Timeseries Engine).
On Topics
Consumer groups also work with durable topics:
CREATE CONSUMER GROUP processors ON order_events;
SELECT * FROM TOPIC order_events CONSUMER GROUP processors LIMIT 100;
COMMIT OFFSETS ON order_events CONSUMER GROUP processors;
Consumers resume from their last committed offset after disconnect.