文档首页/ 分布式消息服务Kafka版/ API参考/ 历史API/ API V2/ 消费组管理/ 重置消费组消费进度到指定位置
更新时间:2025-12-24 GMT+08:00
分享

重置消费组消费进度到指定位置

功能介绍

Kafka实例不支持在线重置消费进度。在执行重置消费进度之前,必须停止被重置消费组客户端。停止待重置消费组客户端,然后等待一段时间(即ConsumerConfig.SESSION_TIMEOUT_MS_CONFIG配置的时间,默认为1000毫秒)后,服务端才认为此消费组客户端已下线。

当前页面API为历史版本API,未来可能停止维护。请使用重置消费组消费进度到指定位置

调用方法

请参见如何调用API

URI

POST /v2/{project_id}/instances/{instance_id}/management/groups/{group}/reset-message-offset

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

项目ID,获取方式请参见获取项目ID

instance_id

String

实例ID。

group

String

消费组名称。

请求参数

表2 请求Body参数

参数

是否必选

参数类型

描述

topic

String

topic名称。

partition

Integer

分区编号,默认值为-1,若传入值为-1,则重置所有分区。

message_offset

Long

重置消费进度到指定偏移量。

  • 如果传入offset小于当前最小的offset,则重置到最小的offset。
  • 如果大于最大的offset,则重置到最大的offset。

message_offset、timestamp二者必选其一。

timestamp

Long

重置消费进度到指定时间,格式为unix时间戳,单位为毫秒。

  • 如果传入timestamp早于当前最早的timestamp,则重置到最早的timestamp。
  • 如果晚于最晚的timestamp,则重置到最晚的timestamp。

message_offset、timestamp二者必选其一。

响应参数

请求示例

  • 重置的消费进度到指定偏移量。
    POST https://{endpoint}/v2/{project_id}/instances/{instance_id}/management/groups/{group}/reset-message-offset
    
    {
      "topic" : "test",
      "partition" : 0,
      "message_offset" : 10
    }
  • 重置的消费进度到指定时间。
    POST https://{endpoint}/v2/{project_id}/instances/{instance_id}/management/groups/{group}/reset-message-offset
    
    {
      "topic" : "test",
      "partition" : 0,
      "timestamp" : 1571812144000
    }

响应示例

状态码

状态码

描述

204

重置消费组消息进度到指定位置操作成功。

错误码

请参见错误码

相关文档