我正在尝试使用最新的Kafka CLI工具重置消费者偏移.
kafka-consumer-groups.bat --bootstrap-server kafka-host:9092 --group my-group --reset-offsets --to-earliest --all-topics
Run Code Online (Sandbox Code Playgroud)
结果我看到了这个输出:
TOPIC PARTITION NEW-OFFSET
FirstTopic 0 0
SecondTopic 0 0
Run Code Online (Sandbox Code Playgroud)
但再次运行命令:
kafka-consumer-groups.bat --bootstrap-server kafka-host:9092 --group my-group --describe
Run Code Online (Sandbox Code Playgroud)
结果输出:
Consumer group 'my-group' has no active members.
TOPIC PARTITION CURRENT-OFFSET LOG-END-OFFSET LAG
FirstTopic 0 1230 1230 0
SecondTopic 0 1022 1022 0
Run Code Online (Sandbox Code Playgroud)
我尝试过其他选项,例如重置为显式偏移或直接指定主题但结果相同.输出表明操作成功,同时使用describe命令检查偏移或调试显示偏移未被更改.
任何人都可以在非动物园管理员经纪人中重置消费者抵消.
我想将mytopic具有 1 个分区且给定组 IDtestgroup1为 0 的主题的偏移量设置为 0。但这并不总是可行。如果我想将偏移量设置为 0,我会收到以下消息:
bash-4.4# kafka-consumer-groups.sh --bootstrap-server localhost:9092 --topic mytopic --group testgroup1 --reset-offsets --to-offset 0 --execute
[2021-06-04 09:23:30,854] WARN New offset (0) is lower than earliest offset for topic partition mytopic-0. Value will be set to 1365671 (kafka.admin.ConsumerGroupCommand$)
bash-4.4# kafka-topics.sh --bootstrap-server localhost:9092 --topic mytopic --describe
Topic: mytopic PartitionCount: 1 ReplicationFactor: 1 Configs: segment.bytes=1073741824
Topic: mytopic Partition: 0 Leader: 1001 Replicas: 1001 Isr: 1001
bash-4.4# kafka-configs.sh --bootstrap-server localhost:9092 --describe --entity-name mytopic --entity-type topics …Run Code Online (Sandbox Code Playgroud) 我正在尝试编写一些内容,该内容将采用以下格式的 UTC 时间字符串,并将其格式化为从手机获取的本地时区。然而,尽管查看SimpleDateFormat 文档,我还是遇到了我的示例字符串无法解析的错误:
W/System.err? java.text.ParseException: Unparseable date: "2014-07-16T21:00:00:000+0000" (at offset 19)
W/System.err? at java.text.DateFormat.parse(DateFormat.java:555)
[...]
D/Set time:? Wed Jul 16 15:10:03 PDT 2014
D/TimeInMilli:? 1405548603565
Run Code Online (Sandbox Code Playgroud)
代码:
Calendar cal = Calendar.getInstance();
TimeZone tz = cal.getTimeZone(); //Get phone's PST zone
String UTCinput = "2014-07-16T21:00:00:000+0000"; //2:00PM PST
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
format.setTimeZone(tz);
Date dateCal = new Date();
try {
dateCal = format.parse(UTCinput);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
cal.setTime(dateCal);
Log.d("Set time: ", String.valueOf(dateCal)); …Run Code Online (Sandbox Code Playgroud)