Resets the consumer offsets of the subscribed topics of a consumer group.
Operation description
You can call this operation to reset the consumer offset of a specific consumer group. You can use the timestamp or offset parameter to reset the consumer offset of a consumer group. You can implement the following features by configuring a combination of different parameters:
- Reset the consumer offsets of one or all subscribed topics of a consumer group to the latest offset. This way, you can consume messages in the topics from the latest offset.
- Reset the consumer offsets of one or all subscribed topics of a consumer group to a specific point in time. This way, you can consume messages in the topics from the specified point in time.
- Reset the consumer offset of one subscribed topic of a consumer group to a specific offset in a specific partition. This way, you can consume messages from the specified offset in the specified partition.
Debugging
Authorization information
The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action
policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:
- Operation: the value that you can use in the Action element to specify the operation on a resource.
- Access level: the access level of each operation. The levels are read, write, and list.
- Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
- The required resource types are displayed in bold characters.
- If the permissions cannot be granted at the resource level,
All Resources
is used in the Resource type column of the operation.
- Condition Key: the condition key that is defined by the cloud service.
- Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
Operation | Access level | Resource type | Condition key | Associated operation |
---|---|---|---|---|
alikafka:UpdateGroup | Write |
|
| none |
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
InstanceId | string | Yes | The instance ID. | alikafka_post-cn-mp91inkw**** |
Topic | string | Yes | The topic name.
**If you want to reset the consumer offsets of all topics to which the consumer subscribes, specify an empty string. | topic_name |
RegionId | string | Yes | The region ID of the instance to which the consumer group belongs. | cn-hangzhou |
ConsumerId | string | Yes | The name of the consumer group.
| kafka-test |
ResetType | string | No | The method that is used to reset the consumer offsets of the subscribed topics of a consumer group. Valid values:
| timestamp |
Time | string | No | The point in time when message consumption starts. The value of this parameter is a UNIX timestamp in milliseconds. The value of this parameter must be less than 0 or within the retention period of the consumer offset. This parameter takes effect only if you set resetType to timestamp.
| -1 |
Offsets | object [] | No | If you set resetType to offset, you can use this parameter to reset the consumer offset of each partition of a specific topic in the consumer group. | |
Partition | integer | No | The partition ID. | 0 |
Offset | long | No | The consumer offset of the partition. | 1 |
a. If you want to reset the consumer offsets of all subscribed topics of a consumer group to the latest offset, set Time to a value that is less than 0. We recommend that you use -1 as the value. Sample code:
{
"RegionId":"cn-beijing",
"InstanceId":"alikafka_post-cn-xxxxxx",
"Topic":"",
"ConsumerId":"ConsumerGroup1",
"ResetType": timestamp,
"Time":-1,
"Offsets": null
}
b. If you want to reset the consumer offsets of all subscribed topics of a consumer group to a specific point in time, set Time to a UNIX timestamp in milliseconds. Sample code:
{
"RegionId":"cn-beijing",
"InstanceId":"alikafka_post-cn-xxxxxx",
"Topic":"",
"ConsumerId":"ConsumerGroup1",
"ResetType": timestamp,
"Time":1679587200000,
"Offsets": null
}
c. If you want to reset the consumer offset of a specific subscribed topic of a consumer group to the latest offset, set Time to a value that is less than 0. We recommend that you use -1 as the value. Sample code:
{
"RegionId":"cn-beijing",
"InstanceId":"alikafka_post-cn-xxxxxx",
"Topic":"topic1",
"ConsumerId":"ConsumerGroup1",
"ResetType": timestamp,
"Time":-1,
"Offsets": null
}
d. If you want to reset the consumer offset of a specific subscribed topic of a consumer group to a point in time that is specified by Time, set Time to a UNIX timestamp in milliseconds. Sample code:
{
"RegionId":"cn-beijing",
"InstanceId":"alikafka_post-cn-xxxxxxx",
"Topic":"topic1",
"ConsumerId":"ConsumerG1",
"ResetType": timestamp,
"Time":1679587200000,
"Offsets": null
}
e. If you want to reset the consumer offset of a specific subscribed topic of a consumer group to a specific offset in a specific partition, refer to the following sample code:
{
"RegionId":"cn-beijing",
"InstanceId":"alikafka_post-cn-xxxxxxx",
"Topic":"topic1",
"ConsumerId":"ConsumerG1",
"Time":-1,
"ResetType":"offset",
"Offsets":"[{\"partition\":1,\"offset\":1},{\"partition\":2,\"offset\":2},{\"partition\":3,\"offset\":3}]"
}
Response parameters
Examples
Sample success responses
JSON
format
{
"Success": true,
"RequestId": "56729737-C428-4E1B-AC68-7A8C2D5****",
"Code": 200,
"Message": "operation success"
}
Error codes
For a list of error codes, visit the Service error codes.
Change history
Change time | Summary of changes | Operation | ||
---|---|---|---|---|
2024-03-15 | The internal configuration of the API is changed, but the call is not affected | see changesets | ||
|