All Products
Search
Document Center

ApsaraMQ for Kafka:Reset consumer offsets

Last Updated:Dec 01, 2023

If you reset a consumer offset, the offset from which a consumer starts to consume messages is changed. If faults occur or wrong messages are consumed during message consumption, you can reset the consumer offset to roll back the consumption to a specific offset or an offset in a partition for reconsumption. You can also change the offset to the latest offset and temporarily leave the accumulated messages unhandled.

Prerequisites

All consumers are stopped. ApsaraMQ for Kafka no longer supports the resetting of offsets during client connection.

Important

ApsaraMQ for Kafka considers a consumer stopped only after the period of time specified by the ConsumerConfig.SESSION_TIMEOUT_MS_CONFIG parameter elapses. The default value of the parameter is 10000, in milliseconds.

Background information

ApsaraMQ for Kafka allows you to reset consumer offsets by using one of the following methods:

  • Start consumption from the latest offset: If you use this method, accumulated messages on the broker are no longer consumed.

    Note

    This method changes only the consumer offset. The accumulated messages are not deleted.

  • Start consumption from a specific point in time: If you use this method, the consumer offset is reset to a specific point in time in the past based on the time when a message is stored in a topic.

  • Start consumption from a specific offset in a partition: If messages are accumulated in only a small number of partitions, you can reset the consumer offsets of only the specified partitions to prevent repeated consumption of messages that are correctly processed in other partitions.

Procedure

  1. Log on to the ApsaraMQ for Kafka console.

  2. In the Resource Distribution section of the Overview page, select the region where the ApsaraMQ for Kafka instance that you want to manage resides.

  3. On the Instances page, click the name of the instance that you want to manage.

  4. In the left-side navigation pane, click Groups.

  5. On the Groups page, find the group that you want to manage and choose More > Reset Consumer Offset in the Actions column.

  6. In the Reset Consumer Offset of Group panel that appears, read the prerequisites and configure a reset policy.

    1. Configure the Reset All Topics parameter.

      • Select Yes to reset the consumer offset for each topic.

      • Select No and enter the name of the topic for which you want to reset the consumer offset in the Topic field.

    2. Configure the Reset Method parameter.

      • Select Reset Consumer Offset to Latest Offset to reset the consumer offset to the latest offset. Then, click OK.

      • Select Reset Consumer Offset to Offset at Specified Point in Time. In the Point in Time field, click the 日历 icon. In the date and time picker that appears, specify a point in time from which you want the group to consume messages. Then, click OK.

      • Select Reset Consumer Offsets by Partition. In the Consumer Offset field, find a partition, enter an integer in the field next to the partition as the offset from which you want the group to consume messages, and then click OK.

  7. In the Note message, click OK.

References

  • For information about how to reset a consumer offset by calling the corresponding API operation, see UpdateConsumerOffset.

  • After a consumer offset is reset, you can view the consumption status to obtain information about the latest consumer offset. For more information, see View consumer information.