kafka 重放 重播 从某个时间点或者offset开始消费
2024-09-06 09:39:49
转自: https://www.jianshu.com/p/932663e9a226
consumer.subscribe(topicA);
consumer.poll(100);//正常订阅topic和poll消息 Set<TopicPartition> assignments = consumer.assignment();//获取consumer所分配的分区信息
Map<TopicPartition, Long> query = new HashMap<>();//构造offsetsForTimes参数,通过时间戳找到offset
for (TopicPartition topicPartition : assignments) {
System.out.println(topicPartition);
query.put(topicPartition, 1550804131000L);
}
Map<TopicPartition, OffsetAndTimestamp> result = consumer.offsetsForTimes(query);
for (Map.Entry<TopicPartition, OffsetAndTimestamp> entry : result.entrySet()) {
System.out.println(entry);
consumer.seek(entry.getKey(), entry.getValue().offset());//每个topic的partition都seek到执行的offset
}
最新文章
- Android基础 : Android ContentProvider
- 关于AlertDialog.Builder(Context context)中所应传入的context
- hdu 4401 Battery
- JAVA CAS原理
- tomcat部署
- MVC1
- BNUOJ-26482 Juice 树形DP
- hdu 5625 Clarke and chemistry
- OAuth认证的过程
- Node.js学习笔记2(安装和配置Node.js)
- Tomcat中配置自定义404错误页面
- Mysql中如何创建、删除授权用户
- vs打开项目出错:未找到导入的项目“C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations\CUDA 5.0.props”的解决办法
- 构建具有用户身份认证的 Ionic 应用
- Elasticsearch-6.7.0系列(一)9200端口 .tar.gz版本centos7环境--下载安装运行
- Docker数据卷Volume实现文件共享、数据迁移备份(三)--技术流ken
- spring3-mvc-maven-hello-world-master mvn jetty:run 及 mvn war:war 指令
- 如何在Markdown文档中插入空格?
- hmac库 密钥相关的哈希运算消息认证码
- 位(bit)与字节(byte)
热门文章
- C# Winform更换Webbrowse为WebKit
- linux的装配与虚拟机的快照
- 朝花夕拾《精通CSS》一、HTML &; CSS 的基础
- ETCD:gRPC代理
- 使用vue-cli创建工程的时候提示vue-cli Failed to download repo vuejs-templates/webpack-simple:self signed certificate in certificate chain的解决方法
- [Spring cloud 一步步实现广告系统] 10. 使用Ribbon 实现微服务调用
- centos7.2安装及管理docker
- golang 处理 json 结构体
- Selenium(四):CSS选择器(一)
- arcgis api 4.x for js 图层拓展篇之mapvLayer(附源码下载)