Resets the consumer offset of a consumer group to a specified timestamp.
Note
You can call this operation to clear queued messages or reconsume messages. You can clear queued messages by using one of the following methods:
- Clear all queued messages in a specified topic.
- Clear the messages that were published to the specified topic before a specified point in time.
Request limit
Each Alibaba Cloud account can call this operation up to 10 times per second. If the number of requests that you send to call this operation within one second reaches the request limit, new requests fail. This may interrupt your business. For information about the request limit of each operation, see API request limits.
Authorization
By default, Alibaba Cloud accounts can call this operation. A Resource Access Management (RAM) user can call this operation only after the RAM user is granted the required permissions. The following table describes the permissions that must be granted to a RAM user to call this operation. For information about how to grant permissions, see Policies.
API |
Action |
Resource in an instance that uses a namespace |
Resource in an instance that does not use a namespace |
---|---|---|---|
OnsConsumerResetOffset |
mq:QueryInstanceBaseInfo mq:ResetConsumerOffset |
acs:mq:*:*:{instanceId}%{topic} |
acs:mq:*:*:{topic} |
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
Action | String | Yes | OnsConsumerResetOffset |
The operation that you want to perform. Set the value to OnsConsumerResetOffset. |
GroupId | String | Yes | GID_test_consumer_id |
The ID of the consumer group for which you want to reset the consumer offset. |
Topic | String | Yes | test-mq-topic |
The name of the topic on which you want to reset the consumer offset. |
Type | Integer | Yes | 1 |
The method that you want to use to clear queued messages. Valid values:
|
ResetTimestamp | Long | No | 1591153871000 |
The point in time to which you want to reset the consumer offset. This parameter takes effect only when you set the Type parameter to 1. Unit: milliseconds. |
InstanceId | String | Yes | MQ_INST_111111111111_DOxxxxxx |
The ID of the Message Queue for Apache RocketMQ instance which contains the specified consumer group. |
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
RequestId | String | D52C68F8-EC5D-4294-BFFF-1A6A25AF**** |
The ID of the request. The system generates a unique ID for each request. You can troubleshoot issues based on the request ID. |
Examples
Sample requests
http(s)://ons.cn-hangzhou.aliyuncs.com/?Action=OnsConsumerResetOffset
&GroupId=GID_test_consumer_id
&InstanceId=MQ_INST_111111111111_DOxxxxxx
&Topic=test-mq-topic
&Type=1
&ResetTimestamp=1591153871000
&<Common request parameters>
Sample success responses
XML
format
HTTP/1.1 200 OK
Content-Type:application/xml
<OnsConsumerResetOffsetResponse>
<RequestId>D52C68F8-EC5D-4294-BFFF-1A6A25AF****</RequestId>
</OnsConsumerResetOffsetResponse>
JSON
format
HTTP/1.1 200 OK
Content-Type:application/json
{
"RequestId" : "D52C68F8-EC5D-4294-BFFF-1A6A25AF****"
}
Error codes
For a list of error codes, visit the API Error Center.
Reset the consumer offset of a consumer group in the console
In the Message Queue for Apache RocketMQ console, you can reset the consumer offset for a consumer group. For more information, see Reset consumer offsets.