Consumer Groups
Connections that the provider makes to Apache Kafka are always part of a consumer group. You can control the consumer group by setting a value for the ConsumerGroupId connection property. Using the same consumer group Id across multiple connections puts those connections into the same consumer group. If you do not provide an Id, the provider generates a random consumer group Id.
All members of a consumer group share an offset that determines what messages are read next within each topic and partition. The provider supports two ways of updating the offset:
- If AutoCommit is enabled, the provider periodically commits the offset for any topics and partitions that have been read by SELECT queries. The exact interval is determined by the auto-commit properties in the native library. See ConsumerProperties for details on how to configure these properties.
- The Commit Offset stored procedure stores the offset of the last item read by the current query. You must call this while the query resultset is still open because the provider resets the offset when the resultset is closed.
If there is no existing offset, the provider uses the OffsetResetStrategy to determine what the offset should be. This can happen if the broker does not recognize the consumer group or if the consumer group never committed an offset.