Resets the consumer offset of a specified group ID to a specified timestamp.

You can call this operation to clear accumulated messages or trace back consumption. You can clear accumulated messages by using one of the following methods:

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

Debugging

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 you want to reset.

InstanceId String Yes MQ_INST_111111111111_DOxxxxxx

The ID of the instance that corresponds to the consumer group ID whose consumer offset you want to reset.

Topic String Yes test-mq-topic

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

Type Integer Yes 1

The message clearing type. Valid values:

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

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

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

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

ResetTimestamp Long No 1591153871000

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

Response parameters

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

The ID of the request, which is a common parameter. Each request has a unique ID.

Examples

Sample requests

http(s)://[Endpoint]/? 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

<OnsConsumerResetOffsetResponse>
      <RequestId>D52C68F8-EC5D-4294-BFFF-1A6A25AFBE54</RequestId>
</OnsConsumerResetOffsetResponse>

JSON format

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

Error codes

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