Resets the consumption offset of consumers with a specified group ID to a specified timestamp.

The operation is used to clear accumulated messages or trace back consumption. The following two ways can help you clear accumulated messages:

  • Clear all messages.
  • Clear messages sent before a specified time.


OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

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 consumer group ID whose consumer offset needs to be reset.

InstanceId String Yes MQ_INST_111111111111_DOxxxxxx

The ID of the Message Queue for Apache RocketMQ instance corresponding to the consumer group ID.

Topic String Yes test-mq-topic

The name of the topic for which you want to reset the offset.

Type Integer Yes 1

The message clearing type. Valid values:

  • 0: clears all messages. When consuming messages in this topic, consumers corresponding to the group ID skip all the accumulated (unconsumed) messages and start to consume from the latest message sent.

    If the program returns "reconsumeLater", this indicates that the relevant messages are in the retry process and cannot be skipped.

  • 1: clears messages sent before a specified time. Only the messages sent after the specified time are consumed.

    The time range allowed for selection ranges from the production time of the earliest message stored in the topic to that of the latest message stored in the topic. You can only select a time within the allowed time range.

ResetTimestamp Long No 1591153871000

The timestamp to which you want to reset the consumer offset. It takes effect only when the Type parameter is set to1. Unit: milliseconds.

Response parameters

Parameter Type Example Description
RequestId String D52C68F8-EC5D-4294-BFFF-1A6A25AFBE54

The ID of the request.


Sample requests

http(s)://[Endpoint]/? Action=OnsConsumerResetOffset
&<Common request parameters>

Sample success responses

XML format


JSON format

    "RequestId": "D52C68F8-EC5D-4294-BFFF-1A6A25AFBE54"

Error codes

For a list of error codes, visit the API Error Center.