kafka-消费者组-点对点测试

文章目录

  • 1、点对点测试
    • 1.1、获取 kafka-consumer-groups.sh 的帮助信息
    • 1.2、列出所有的 消费者组
    • 1.3、创建消费者1并指定组 my_group1
    • 1.4、创建消费者2并指定组 my_group1
    • 1.5、创建消费者3并指定组 my_group1
    • 1.6、创建生产者发送消息到 my_topic1 主题
      • 1.6.1、发送第一条消息romantic
      • 1.6.2、发送第二条消息access
      • 1.6.3、发送第三条消息ability
      • 1.6.4、发送第四条消息accompany
      • 1.6.5、发送第五条消息abandon

1、点对点测试

1.1、获取 kafka-consumer-groups.sh 的帮助信息

[root@localhost ~]# kafka-consumer-groups.sh --help
Missing required argument "[bootstrap-server]"
Option                                  Description                            
------                                  -----------                            
--all-groups                            Apply to all consumer groups.          
--all-topics                            Consider all topics assigned to a      group in the `reset-offsets` process.
--bootstrap-server <String: server to   REQUIRED: The server(s) to connect to. connect to>                                                                  
--by-duration <String: duration>        Reset offsets to offset by duration    from current timestamp. Format:      'PnDTnHnMnS'                         
--command-config <String: command       Property file containing configs to be config property file>                   passed to Admin Client and Consumer. 
--delete                                Pass in groups to delete topic         partition offsets and ownership      information over the entire consumer group. For instance --group g1 --    group g2                             
--delete-offsets                        Delete offsets of consumer group.      Supports one consumer group at the   time, and multiple topics.           
--describe                              Describe consumer group and list       offset lag (number of messages not   yet processed) related to given      group.                               
--dry-run                               Only show results without executing    changes on Consumer Groups.          Supported operations: reset-offsets. 
--execute                               Execute operation. Supported           operations: reset-offsets.           
--export                                Export operation execution to a CSV    file. Supported operations: reset-   offsets.                             
--from-file <String: path to CSV file>  Reset offsets to values defined in CSV file.                                
--group <String: consumer group>        The consumer group we wish to act on.  
--help                                  Print usage information.               
--list                                  List all consumer groups.              
--members                               Describe members of the group. This    option may be used with '--describe' and '--bootstrap-server' options     only.                                Example: --bootstrap-server localhost: 9092 --describe --group group1 --    members                              
--offsets                               Describe the group and list all topic  partitions in the group along with   their offset lag. This is the        default sub-action of and may be     used with '--describe' and '--       bootstrap-server' options only.      Example: --bootstrap-server localhost: 9092 --describe --group group1 --    offsets                              
--reset-offsets                         Reset offsets of consumer group.       Supports one consumer group at the   time, and instances should be        inactive                             Has 2 execution options: --dry-run     (the default) to plan which offsets  to reset, and --execute to update    the offsets. Additionally, the --    export option is used to export the  results to a CSV format.             You must choose one of the following   reset specifications: --to-datetime, --by-period, --to-earliest, --to-    latest, --shift-by, --from-file, --  to-current.                          To define the scope use --all-topics   or --topic. One scope must be        specified unless you use '--from-    file'.                               
--shift-by <Long: number-of-offsets>    Reset offsets shifting current offset  by 'n', where 'n' can be positive or negative.                            
--state [String]                        When specified with '--describe',      includes the state of the group.     Example: --bootstrap-server localhost: 9092 --describe --group group1 --    state                                When specified with '--list', it       displays the state of all groups. It can also be used to list groups with specific states.                     Example: --bootstrap-server localhost: 9092 --list --state stable,empty     This option may be used with '--       describe', '--list' and '--bootstrap-server' options only.                
--timeout <Long: timeout (ms)>          The timeout that can be set for some   use cases. For example, it can be    used when describing the group to    specify the maximum amount of time   in milliseconds to wait before the   group stabilizes (when the group is  just created, or is going through    some changes). (default: 5000)       
--to-current                            Reset offsets to current offset.       
--to-datetime <String: datetime>        Reset offsets to offset from datetime. Format: 'YYYY-MM-DDTHH:mm:SS.sss'    
--to-earliest                           Reset offsets to earliest offset.      
--to-latest                             Reset offsets to latest offset.        
--to-offset <Long: offset>              Reset offsets to a specific offset.    
--topic <String: topic>                 The topic whose consumer group         information should be deleted or     topic whose should be included in    the reset offset process. In `reset- offsets` case, partitions can be     specified using this format: `topic1:0,1,2`, where 0,1,2 are the          partition to be included in the      process. Reset-offsets also supports multiple topic inputs.               
--verbose                               Provide additional information, if     any, when describing the group. This option may be used with '--          offsets'/'--members'/'--state' and   '--bootstrap-server' options only.   Example: --bootstrap-server localhost: 9092 --describe --group group1 --    members --verbose                    
--version                               Display Kafka version.  

1.2、列出所有的 消费者组

console-consumer-92430 是没有指定组的消费者,默认自己是一组如果没有指定组的消费者长时间关闭,会自动删除组
消费者组:每个消费者不指定组默认自己为一组,指定group相同的消费者他们为一组
一个消费者组同一个消息只能获取消费一次(组内的多个消费者只有一个会消费该消息)
同一个消费者组内的多个消费者 消费一个主题的消息时就是点对点,每个消息消费一次

[root@localhost ~]# kafka-consumer-groups.sh --bootstrap-server 192.168.74.148:9092 --list
console-consumer-92430

1.3、创建消费者1并指定组 my_group1

[root@localhost ~]# kafka-console-consumer.sh --bootstrap-server 192.168.74.148:9092 --topic my_topic1 --group my_group1
[root@localhost ~]# kafka-consumer-groups.sh --bootstrap-server 192.168.74.148:9092 --group my_group1 --describeGROUP           TOPIC           PARTITION  CURRENT-OFFSET  LOG-END-OFFSET  LAG             CONSUMER-ID                                               HOST            CLIENT-ID
my_group1       my_topic1       0          0               0               0               consumer-my_group1-1-c2ff5a19-af5c-47fc-9ad9-d6028844f86c /192.168.74.148 consumer-my_group1-1
my_group1       my_topic1       1          0               0               0               consumer-my_group1-1-c2ff5a19-af5c-47fc-9ad9-d6028844f86c /192.168.74.148 consumer-my_group1-1
my_group1       my_topic1       2          0               0               0               consumer-my_group1-1-c2ff5a19-af5c-47fc-9ad9-d6028844f86c /192.168.74.148 consumer-my_group1-1

1.4、创建消费者2并指定组 my_group1

[root@localhost ~]# kafka-console-consumer.sh --bootstrap-server 192.168.74.148:9092 --topic my_topic1 --group my_group1
[root@localhost ~]# kafka-consumer-groups.sh --bootstrap-server 192.168.74.148:9092 --group my_group1 --describeGROUP           TOPIC           PARTITION  CURRENT-OFFSET  LOG-END-OFFSET  LAG             CONSUMER-ID                                               HOST            CLIENT-ID
my_group1       my_topic1       0          0               0               0               consumer-my_group1-1-c2ff5a19-af5c-47fc-9ad9-d6028844f86c /192.168.74.148 consumer-my_group1-1
my_group1       my_topic1       1          0               0               0               consumer-my_group1-1-c2ff5a19-af5c-47fc-9ad9-d6028844f86c /192.168.74.148 consumer-my_group1-1
my_group1       my_topic1       2          0               0               0               consumer-my_group1-1-c6a31cdb-c924-49bb-99da-cf45ffdbefb6 /192.168.74.148 consumer-my_group1-1

1.5、创建消费者3并指定组 my_group1

[root@localhost ~]# kafka-console-consumer.sh --bootstrap-server 192.168.74.148:9092 --topic my_topic1 --group my_group1
[root@localhost ~]# kafka-consumer-groups.sh --bootstrap-server 192.168.74.148:9092 --group my_group1 --describeGROUP           TOPIC           PARTITION  CURRENT-OFFSET  LOG-END-OFFSET  LAG             CONSUMER-ID                                               HOST            CLIENT-ID
my_group1       my_topic1       1          0               0               0               consumer-my_group1-1-c2ff5a19-af5c-47fc-9ad9-d6028844f86c /192.168.74.148 consumer-my_group1-1
my_group1       my_topic1       2          0               0               0               consumer-my_group1-1-c6a31cdb-c924-49bb-99da-cf45ffdbefb6 /192.168.74.148 consumer-my_group1-1
my_group1       my_topic1       0          0               0               0               consumer-my_group1-1-19852a4a-9a4e-4b41-b605-0a78530d0cd8 /192.168.74.148 consumer-my_group1-1

1.6、创建生产者发送消息到 my_topic1 主题

1.6.1、发送第一条消息romantic

发送单词romantic

[root@localhost ~]# kafka-console-producer.sh --bootstrap-server 192.168.74.148:9092 --topic my_topic1
>romantic
>

在这里插入图片描述

发送一个消息romantic后发现消费者3中的 current-offset 和 log-end-offset 都变成了1

[root@localhost ~]# kafka-consumer-groups.sh --bootstrap-server 192.168.74.148:9092 --group my_group1 --describeGROUP           TOPIC           PARTITION  CURRENT-OFFSET  LOG-END-OFFSET  LAG             CONSUMER-ID                                               HOST            CLIENT-ID
my_group1       my_topic1       1          0               0               0               consumer-my_group1-1-c2ff5a19-af5c-47fc-9ad9-d6028844f86c /192.168.74.148 consumer-my_group1-1
my_group1       my_topic1       2          0               0               0               consumer-my_group1-1-c6a31cdb-c924-49bb-99da-cf45ffdbefb6 /192.168.74.148 consumer-my_group1-1
my_group1       my_topic1       0          1               1               0               consumer-my_group1-1-19852a4a-9a4e-4b41-b605-0a78530d0cd8 /192.168.74.148 consumer-my_group1-1

1.6.2、发送第二条消息access

在这里插入图片描述

发送一个消息access后发现消费者2中的 current-offset 和 log-end-offset 都变成了1

[root@localhost ~]# kafka-consumer-groups.sh --bootstrap-server 192.168.74.148:9092 --group my_group1 --describeGROUP           TOPIC           PARTITION  CURRENT-OFFSET  LOG-END-OFFSET  LAG             CONSUMER-ID                                               HOST            CLIENT-ID
my_group1       my_topic1       1          0               0               0               consumer-my_group1-1-c2ff5a19-af5c-47fc-9ad9-d6028844f86c /192.168.74.148 consumer-my_group1-1
my_group1       my_topic1       2          1               1               0               consumer-my_group1-1-c6a31cdb-c924-49bb-99da-cf45ffdbefb6 /192.168.74.148 consumer-my_group1-1
my_group1       my_topic1       0          1               1               0               consumer-my_group1-1-19852a4a-9a4e-4b41-b605-0a78530d0cd8 /192.168.74.148 consumer-my_group1-1

1.6.3、发送第三条消息ability

在这里插入图片描述

发送一个消息ability后发现消费者3中的 current-offset 和 log-end-offset 都变成了2,因为第一次消息也是消费者3接收

[root@localhost ~]# kafka-consumer-groups.sh --bootstrap-server 192.168.74.148:9092 --group my_group1 --describeGROUP           TOPIC           PARTITION  CURRENT-OFFSET  LOG-END-OFFSET  LAG             CONSUMER-ID                                               HOST            CLIENT-ID
my_group1       my_topic1       1          0               0               0               consumer-my_group1-1-c2ff5a19-af5c-47fc-9ad9-d6028844f86c /192.168.74.148 consumer-my_group1-1
my_group1       my_topic1       2          1               1               0               consumer-my_group1-1-c6a31cdb-c924-49bb-99da-cf45ffdbefb6 /192.168.74.148 consumer-my_group1-1
my_group1       my_topic1       0          2               2               0               consumer-my_group1-1-19852a4a-9a4e-4b41-b605-0a78530d0cd8 /192.168.74.148 consumer-my_group1-1

1.6.4、发送第四条消息accompany

在这里插入图片描述

发送一个消息accompany后发现消费者2中的 current-offset 和 log-end-offset 都变成了2,因为第二次消息也是消费者2接收

[root@localhost ~]# kafka-consumer-groups.sh --bootstrap-server 192.168.74.148:9092 --group my_group1 --describeGROUP           TOPIC           PARTITION  CURRENT-OFFSET  LOG-END-OFFSET  LAG             CONSUMER-ID                                               HOST            CLIENT-ID
my_group1       my_topic1       1          0               0               0               consumer-my_group1-1-c2ff5a19-af5c-47fc-9ad9-d6028844f86c /192.168.74.148 consumer-my_group1-1
my_group1       my_topic1       2          2               2               0               consumer-my_group1-1-c6a31cdb-c924-49bb-99da-cf45ffdbefb6 /192.168.74.148 consumer-my_group1-1
my_group1       my_topic1       0          2               2               0               consumer-my_group1-1-19852a4a-9a4e-4b41-b605-0a78530d0cd8 /192.168.74.148 consumer-my_group1-1

1.6.5、发送第五条消息abandon

在这里插入图片描述

发送一个消息abandon后发现消费者1中的 current-offset 和 log-end-offset 都变成了1,因为消费者1是第一次接收到消息

[root@localhost ~]# kafka-consumer-groups.sh --bootstrap-server 192.168.74.148:9092 --group my_group1 --describeGROUP           TOPIC           PARTITION  CURRENT-OFFSET  LOG-END-OFFSET  LAG             CONSUMER-ID                                               HOST            CLIENT-ID
my_group1       my_topic1       1          1               1               0               consumer-my_group1-1-c2ff5a19-af5c-47fc-9ad9-d6028844f86c /192.168.74.148 consumer-my_group1-1
my_group1       my_topic1       2          2               2               0               consumer-my_group1-1-c6a31cdb-c924-49bb-99da-cf45ffdbefb6 /192.168.74.148 consumer-my_group1-1
my_group1       my_topic1       0          2               2               0               consumer-my_group1-1-19852a4a-9a4e-4b41-b605-0a78530d0cd8 /192.168.74.148 consumer-my_group1-1

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/web/18389.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

华为WLAN无线组网技术与解决方案

WLAN无线组网技术与解决方案 网络拓扑采用AP和AC旁挂式无线组网 配置思路&#xff1a; 1.让AP上线 1.1&#xff0c;使得AP能够获得IP地址 配置步骤&#xff1a; 1.把AC当作一个一个有管理功能的三层交换机 sys Enter system view, return user view with CtrlZ. [AC6605]vlan …

多态的好处

使用多态&#xff08;Polymorphism&#xff09;在C中有多个重要的原因&#xff0c;这些原因使得多态成为面向对象编程中不可或缺的一部分。以下是使用多态的一些关键原因&#xff1a; 代码复用和灵活性&#xff1a; 多态允许我们编写可以处理多种类型对象的通用代码。通过使用…

为什么MySQL需要binlog、undo log、redo log 3种日志?

binlog是 server层生成的日记&#xff0c;而 undo log、redo log 是Innodb 存储引擎层生成的日志 binlog&#xff0c;是 binary log的英文缩写&#xff0c;翻译为二进制日志或者归档日志&#xff08;带有业务含义&#xff09;&#xff0c;它是从 MySQL 3.23.14版本引入的。bin…

高并发处理

高并发处理是对系统在同时处理大量请求能力的一种考验。在设计高并发系统时&#xff0c;通常会涉及到多个层面的优化&#xff0c;包括应用程序、数据库、服务器和网络架构等方面的优化。以下是一些建议如何设计和优化高并发系统&#xff1a; 应用程序层面 &#xff1a; 异步处…

【Qt】Qt框架文件处理精要:API解析与应用实例:QFile

文章目录 前言&#xff1a;1. Qt 文件概述2. 输入输出设备类3. 文件读写类3.1. 打开open3.2. 读read / readline/ readAll3.3. 写write3.4. 关闭close 4. 读写文件示例5. 文件件和目录信息类总结&#xff1a; 前言&#xff1a; 在现代软件开发中&#xff0c;文件操作是应用程序…

【贪吃蛇game】

好的&#xff0c;我将为您编写一个简单的贪吃蛇游戏的代码。这个游戏将使用Python语言和pygame库来实现。首先&#xff0c;请确保您的环境中已经安装了pygame库。如果尚未安装&#xff0c;可以使用pip install pygame命令进行安装。 接下来&#xff0c;我将编写代码。代码完成后…

如何恢复已删除/丢失或未保存的 PDF 文件?

许多用户曾因某些问题删除或丢失 PDF 文件。此外&#xff0c;一些用户在关闭应用程序时未保存 PDF 文件&#xff0c;从而丢失 PDF 文件。您可以尝试一些解决方案来恢复已删除的 PDF 文件、恢复未保存的 PDF 文件&#xff0c;以及在任何其他数据丢失情况下挽救丢失的 PDF 文件。…

优化效率,简化流程:探索工资结算系统的重要性与实施方法

在现代企业中&#xff0c;工资结算是一项重要而复杂的任务。为了更好地管理和处理员工的工资事务&#xff0c;许多企业采用工资结算系统。本文将探讨工资结算系统的重要性&#xff0c;并介绍一些实施该系统的方法。 ### 1. 概述 工资结算系统是一种自动化的软件系统&#xff0…

apexcharts数据可视化之极坐标区域图

apexcharts数据可视化之极坐标区域图 有完整配套的Python后端代码。 本教程主要会介绍如下图形绘制方式&#xff1a; 基础极坐标区域图单色极坐标区域图 基础极坐标区域图 import ApexChart from react-apexcharts;export function BasicPolar() {// 数据序列const series…

【论文阅读|cryoET】DeepETPicker:使用弱监督深度学习的快速准确cryoET三维颗粒挑选算法

题目 DeepETPicker: Fast and accurate 3D particle picking for cryo-electron tomography using weakly supervised deep learning 发表期刊&#xff1a; Nature Communications 发表时间&#xff1a;2024.02 Accepted 作者&#xff1a;Guole Liu, Tongxin Niu 中科院自动化…

2024全新升级版家政服务小程序源码 支持家政预约+上门服务+SAAS系统+可二开

随着科技的飞速发展&#xff0c;家政服务行业也迎来了数字化转型的浪潮。为了满足市场日益增长的需求&#xff0c;分享一款2024全新升级版的家政服务小程序源码。该源码不仅支持家政预约和上门服务&#xff0c;还集成了SAAS系统&#xff0c;并支持二次开发&#xff0c;为用户带…

FLUKE福禄克DSX-5000或者DSX-8000如何做外部串扰测试之实践篇

近期&#xff0c;有很多朋友问如何使用DSX5000或者DSX8000测外部串扰&#xff1f; 外部串扰测试在判定外部线缆是否对网络传输造成影响的重要一环。 直接上干货&#xff0c;测试步骤如下&#xff1a; 第一步:对主机和副机进行基准设置&#xff0c;保持同步!官方是建议每24小时…

Discourse 安装后安全配置考虑

防火墙 防火墙是肯定要装机器上的&#xff0c;并且端口只开放了 443 和 22。 22 的端口还只限制了部分 IP 段的访问&#xff0c;通常只允许给内部网络的 SSH。 Web 服务应该只走 443&#xff0c;80 端口的做好自动重定向到 443。 CloudFlare 可以用一个 CloudFlare 的负载…

网络编程基础(四)

目录 前言 二、多点通信 2.1 单播 2.2 广播 2.2.1 广播得发送端实现--》类似与UDP的客户端 2.3 组播 2.3.1 组播发送端流程--》类似于UDP的客户端流程 2.3.2 组播的接收端流程---》类似于UDP的服务器端流程 前言 多点通信 一、套接字选项得获取和设置 int getsockopt(int…

Qt信号和槽机制

信号和槽机制的原理是Qt框架中实现对象间通信的一种有效方式。以下是该机制的详细原理解释&#xff1a; 1. 基本概念 信号&#xff08;Signal&#xff09;&#xff1a;特定事件发生时由对象发出的通知。信号是Qt中的一种特殊成员函数&#xff0c;用于在对象状态改变或发生特定…

Linux系统的等保整改

在进行Linux系统的等保整改时&#xff0c;需要遵循一系列步骤和措施以确保系统的安全性得到加强。基于等保的安全加固是一个涉及多个方面的过程&#xff0c;主要包括身份鉴别、访问控制、安全审计、入侵防范、恶意代码防范、可信验证以及数据完整性等方面。下面是具体步骤和建议…

【Javascript修炼篇】一文搞懂Splice 和 Slice区别

它们因不同的目的而生&#xff0c;却在不少场景下长得一副模样。咱们不卖关子&#xff0c;直接开讲&#xff0c;先把这团疑惑的雾拨开。 小贴士 1&#xff1a; 先瞅瞅它们的字面意思 Splice&#xff1a;把&#xff08;绳子的&#xff09;末端交织起来连接或接合。Slice&#…

Owinps静态IP代理:跨境电商的优选解决方案

在快速发展的电子商务领域&#xff0c;尤其是跨境电商行业&#xff0c;网络的稳定性和安全性是成功经营的关键因素之一。在这背后&#xff0c;少不得一个重要的跨境电商工具——代理IP&#xff0c;而这其中&#xff0c;静态IP因其独特的稳定性和安全性&#xff0c;正逐渐成为众…

微信小程序开发(持续更新)

1.项目基本配置 &#xff08;1&#xff09;文件 1&#xff09;主体文件 主体文件&#xff1a;够作用于整个小程序&#xff0c;影响到小程序的每个页面&#xff0c;主体文件必须放到项目的根目录下 由三部分组成&#xff1a; .appjs:小程序入口文件.app.json:小程序的全局配…

linux中使用gdb调试c++的dump文件

1 查看系统是否开启dump生成 0表示没开启 ulimit -c 但是这个只是针对当前这个连接&#xff0c;如果想要永久修改可以修改配置文件&#xff1a;vim /etc/profile&#xff0c;然后添加上面的命令ulimit - c unlimited.然后执行source /etc/profile或者重启使刚刚的配置可以…