RabbitMQ的交换机的四种类型

RabbitMQ的交换机的四种类型

一、Direct类型交换机

Direct类型交换机
///1.在发送消息的时候,通过Direct类型的路由转发;
//要求Direct类型交换机和队列绑定;绑定需要一个标识,生产者在发送消息的时候,也需要指定一个标识,消息发送给交换机以后,交换机进行标识的匹配;知道和交换机绑定队列完全吻合的标识,只要是匹配到了,就把消息通过交换机转发给当前绑定标识吻合的这个队列中去;

//Direct类型的交换机可以做点啥?

//如果说有一个生产者发送了很多消息,需要把消息分类处理;
//消息需要分几类,就可以定义几个队列;分别把队列和交换机在绑定的是偶,分别给出不同的表示,发送消息的时候,就给出不同标识,就可以把消息发送到不同的经过分类的队列中去了;

//记录日志:记录日志,分类的记录,如果是异常,就需要另外的处理;
//还需要来一个所有日志的记录;
//定义一个记录所有日志的队列,定义一个专门为异常日志存在的队列;
//定义一个Dirct类型的交换机,分别绑定不同的标识,日志生产出来以后,就可以根据日志的类型不同,发给路由,把类型作为标识,路由匹配后,就可以转发到不同的队列中去中,就可以把日志分类处理;

生产者

public class DirectExchangeProducer
{public static void Send(){var factory = new ConnectionFactory();factory.HostName = "localhost";//RabbitMQ服务在本地运行factory.UserName = "guest";//用户名factory.Password = "guest";//密码 using (var connection = factory.CreateConnection()){using (IModel channel = connection.CreateModel()){#region 删除队列和交换机channel.ExchangeDelete("DirectExChange");channel.QueueDelete("DirectExchangeLogAllQueue");channel.QueueDelete("DirectExchangeErrorQueue");#endregionchannel.QueueDeclare(queue: "DirectExchangeLogAllQueue", durable: true, exclusive: false, autoDelete: false, arguments: null); channel.QueueDeclare(queue: "DirectExchangeErrorQueue", durable: true, exclusive: false, autoDelete: false, arguments: null); //交换机的类型:type:ExchangeTypechannel.ExchangeDeclare(exchange: "DirectExChange", type: ExchangeType.Direct, durable: true, autoDelete: false, arguments: null);//定义四种类型的日志string[] logtypes = new string[] { "debug", "info", "warn", "error" };//把交换机和队列绑定,把所有的日志类型作为标识绑定起来;//DirectExchangeLogAllQueue:用来接受所有的日志消息//交换机和队列可以绑定多个标识foreach (string logtype in logtypes){channel.QueueBind(queue: "DirectExchangeLogAllQueue",exchange: "DirectExChange",routingKey: logtype);}//针对异常处理的:这里DirectExChange 绑定DirectExchangeErrorQueue,只指定一个标识就是errorchannel.QueueBind(queue: "DirectExchangeErrorQueue",exchange: "DirectExChange",routingKey: "error");//通过取模,得到四种类型的日志各自25个日志信息;List<LogMsgModel> logList = new List<LogMsgModel>();for (int i = 1; i <= 100; i++){if (i % 4 == 0){logList.Add(new LogMsgModel() { LogType = "info", Msg = Encoding.UTF8.GetBytes($"info第{i}条信息") });}if (i % 4 == 1){logList.Add(new LogMsgModel() { LogType = "debug", Msg = Encoding.UTF8.GetBytes($"debug第{i}条信息") });}if (i % 4 == 2){logList.Add(new LogMsgModel() { LogType = "warn", Msg = Encoding.UTF8.GetBytes($"warn第{i}条信息") });}if (i % 4 == 3){logList.Add(new LogMsgModel() { LogType = "error", Msg = Encoding.UTF8.GetBytes($"error第{i}条信息") });}}Console.WriteLine("生产者发送100条日志信息");logList = logList.OrderBy(l => l.LogType).ToList();//发送日志信息foreach (var log in logList){channel.BasicPublish(exchange: "DirectExChange",routingKey: log.LogType,basicProperties: null,body: log.Msg);Console.WriteLine($"{Encoding.UTF8.GetString(log.Msg)}  已发送~~");}}}}public class LogMsgModel{public string LogType { get; set; }public byte[] Msg { get; set; }}
}

消费者

public class DirectExchangeConsumerLogAll
{public static void Consumption(){var factory = new ConnectionFactory();factory.HostName = "localhost";//RabbitMQ服务在本地运行factory.UserName = "guest";//用户名factory.Password = "guest";//密码 using (var connection = factory.CreateConnection()){using (IModel channel = connection.CreateModel()){channel.QueueDeclare(queue: "DirectExchangeLogAllQueue", durable: true, exclusive: false, autoDelete: false, arguments: null);channel.ExchangeDeclare(exchange: "DirectExChange", type: ExchangeType.Direct, durable: true, autoDelete: false, arguments: null);string[] logtypes = new string[] { "debug", "info", "warn", "error" };foreach (string logtype in logtypes){channel.QueueBind(queue: "DirectExchangeLogAllQueue",exchange: "DirectExChange",routingKey: logtype);}//消费队列中的所有消息;                                   var consumer = new EventingBasicConsumer(channel);consumer.Received += (model, ea) =>{var body = ea.Body;var message = Encoding.UTF8.GetString(body.ToArray());Console.WriteLine($"【{message}】,写入文本~~");};//处理消息channel.BasicConsume(queue: "DirectExchangeLogAllQueue",autoAck: true,consumer: consumer);Console.ReadLine();}}}
}

二、fanout 类型交换机

///fanout类型的Exchange路由规则非常简单,它会把所有发送到该Exchange的消息路由到所有与它绑定的Queue中。
//交换机和队列绑定不需要指定标识;对于生产者发过来的消息,发给交换机以后,只要是整个交换机和队列有绑定,交换机就转发给队列;

//生产者发送的消息都可以转发给和他绑定额队列;
//广播式;发布订阅模式;一个生产者把消息发送过去,多个消费者都可以接受到了;

生产者

public class FanoutExchange
{public static void Send(){var factory = new ConnectionFactory();factory.HostName = "localhost";//RabbitMQ服务在本地运行factory.UserName = "guest";//用户名factory.Password = "guest";//密码 using (var connection = factory.CreateConnection()){using (IModel channel = connection.CreateModel()){channel.QueueDeclare(queue: "FanoutExchangeZhaoxi001", durable: true, exclusive: false, autoDelete: false, arguments: null);channel.QueueDeclare(queue: "FanoutExchangeZhaoxi002", durable: true, exclusive: false, autoDelete: false, arguments: null);//在这里声明一个Fanout 类型的交换机channel.ExchangeDeclare(exchange: "FanoutExchange", type: ExchangeType.Fanout, durable: true, autoDelete: false, arguments: null);//交换机绑定队列,不需要标识channel.QueueBind(queue: "FanoutExchangeZhaoxi001", exchange: "FanoutExchange", routingKey: string.Empty, arguments: null);channel.QueueBind(queue: "FanoutExchangeZhaoxi002", exchange: "FanoutExchange", routingKey: string.Empty, arguments: null);//在控制台输入消息,按enter键发送消息int i = 1;while (true){var message = $"通知{i}";if (i>10){Console.WriteLine("请输入通知~~");message = Console.ReadLine();} var body = Encoding.UTF8.GetBytes(message);//基本发布channel.BasicPublish(exchange: "FanoutExchange",routingKey: string.Empty,basicProperties: null,body: body);Console.WriteLine($"通知【{message}】已发送到队列");Thread.Sleep(2000);i++;}}}}
}

消费者

public class FanoutExchange
{public static void Consumption(){var factory = new ConnectionFactory();factory.HostName = "localhost";//RabbitMQ服务在本地运行factory.UserName = "guest";//用户名factory.Password = "guest";//密码 using (var connection = factory.CreateConnection()){//创建通道channelusing (var channel = connection.CreateModel()){channel.QueueDeclare(queue: "FanoutExchangeZhaoxi001", durable: true, exclusive: false, autoDelete: false, arguments: null);channel.QueueDeclare(queue: "FanoutExchangeZhaoxi002", durable: true, exclusive: false, autoDelete: false, arguments: null);//在这里声明一个Fanout 类型的交换机channel.ExchangeDeclare(exchange: "FanoutExchange", type: ExchangeType.Fanout, durable: true, autoDelete: false, arguments: null);//交换机绑定队列,不需要标识channel.QueueBind(queue: "FanoutExchangeZhaoxi001", exchange: "FanoutExchange", routingKey: string.Empty, arguments: null);channel.QueueBind(queue: "FanoutExchangeZhaoxi002", exchange: "FanoutExchange", routingKey: string.Empty, arguments: null);//定义消费者                                      var consumer = new EventingBasicConsumer(channel);consumer.Received += (model, ea) =>{var body = ea.Body;var message = Encoding.UTF8.GetString(body.ToArray());//只是为了演示,并没有存入文本文件Console.WriteLine($"消费者0:接收成功!【{message}】,邮件通知");};Console.WriteLine("消费者0:通知服务准备就绪...");//处理消息channel.BasicConsume(queue: "FanoutExchangeZhaoxi002",autoAck: true,consumer: consumer);Console.ReadLine();}}}public static void Consumption1(){var factory = new ConnectionFactory();factory.HostName = "localhost";//RabbitMQ服务在本地运行factory.UserName = "guest";//用户名factory.Password = "guest";//密码 using (var connection = factory.CreateConnection()){//创建通道channelusing (var channel = connection.CreateModel()){channel.QueueDeclare(queue: "FanoutExchangeZhaoxi001", durable: true, exclusive: false, autoDelete: false, arguments: null);channel.QueueDeclare(queue: "FanoutExchangeZhaoxi002", durable: true, exclusive: false, autoDelete: false, arguments: null);//在这里声明一个Fanout 类型的交换机channel.ExchangeDeclare(exchange: "FanoutExchange", type: ExchangeType.Fanout, durable: true, autoDelete: false, arguments: null);//交换机绑定队列,不需要标识channel.QueueBind(queue: "FanoutExchangeZhaoxi001", exchange: "FanoutExchange", routingKey: string.Empty, arguments: null);channel.QueueBind(queue: "FanoutExchangeZhaoxi002", exchange: "FanoutExchange", routingKey: string.Empty, arguments: null);//定义消费者                                      var consumer = new EventingBasicConsumer(channel);consumer.Received += (model, ea) =>{var body = ea.Body;var message = Encoding.UTF8.GetString(body.ToArray());//只是为了演示,并没有存入文本文件Console.WriteLine($"消费者1:接收成功!【{message}】,邮件通知");};Console.WriteLine("消费者1:通知服务准备就绪...");//处理消息channel.BasicConsume(queue: "FanoutExchangeZhaoxi001",autoAck: true,consumer: consumer);Console.ReadLine();}}}
}

三、Topic 类型交换机

Topic交换机:可以做到模糊匹配;
Exchange绑定队列需要制定标识 标识 可以有自己的规则;标识可以有占位符、通配符;*/#*匹配一个单词、#匹配多个单词,在Direct基础上加上模糊匹配;

生产者

public class TopicExchange
{public static void Send(){var factory = new ConnectionFactory();factory.HostName = "localhost";//RabbitMQ服务在本地运行factory.UserName = "guest";//用户名factory.Password = "guest";//密码 using (var connection = factory.CreateConnection()){using (IModel channel = connection.CreateModel()){//声明一个Topic类型的交换机channel.ExchangeDeclare(exchange: "TopicExchange", type: ExchangeType.Topic, durable: true, autoDelete: false, arguments: null);channel.QueueDeclare(queue: "ChinaQueue", durable: true, exclusive: false, autoDelete: false, arguments: null);channel.QueueDeclare(queue: "newsQueue", durable: true, exclusive: false, autoDelete: false, arguments: null);channel.QueueBind(queue: "ChinaQueue", exchange: "TopicExchange", routingKey: "China.#", arguments: null);channel.QueueBind(queue: "newsQueue", exchange: "TopicExchange", routingKey: "#.news", arguments: null);{string message = "来自中国的新闻消息。。。。";var body = Encoding.UTF8.GetBytes(message);channel.BasicPublish(exchange: "TopicExchange", routingKey: "China.news", basicProperties: null, body: body);Console.WriteLine($"消息【{message}】已发送到队列");}{string message = "来自中国的天气消息。。。。";var body = Encoding.UTF8.GetBytes(message);channel.BasicPublish(exchange: "TopicExchange", routingKey: "China.weather", basicProperties: null, body: body);Console.WriteLine($"消息【{message}】已发送到队列");}{string message = "来自美国的新闻消息。。。。";var body = Encoding.UTF8.GetBytes(message);channel.BasicPublish(exchange: "TopicExchange", routingKey: "usa.news", basicProperties: null, body: body);Console.WriteLine($"消息【{message}】已发送到队列");}{string message = "来自美国的天气消息。。。。";var body = Encoding.UTF8.GetBytes(message);channel.BasicPublish(exchange: "TopicExchange", routingKey: "usa.weather", basicProperties: null, body: body);Console.WriteLine($"消息【{message}】已发送到队列");}}}}
}

消费者

public class TopicExchange
{public static void Consumption(){var factory = new ConnectionFactory();factory.HostName = "localhost";//RabbitMQ服务在本地运行factory.UserName = "guest";//用户名factory.Password = "guest";//密码 using (var connection = factory.CreateConnection()){using (IModel channel = connection.CreateModel()){channel.ExchangeDeclare(exchange: "TopicExchange", type: ExchangeType.Topic, durable: true, autoDelete: false, arguments: null);channel.QueueDeclare(queue: "ChinaQueue", durable: true, exclusive: false, autoDelete: false, arguments: null);channel.QueueBind(queue: "ChinaQueue", exchange: "TopicExchange", routingKey: "China.#", arguments: null);//定义消费者                                      var consumer = new EventingBasicConsumer(channel);consumer.Received += (model, ea) =>{var body = ea.Body;var message = Encoding.UTF8.GetString(body.ToArray());Console.WriteLine($"接收成功!【{message}】");};//处理消息channel.BasicConsume(queue: "ChinaQueue",autoAck: true,consumer: consumer);Console.WriteLine("对来自于中国的消息比较感兴趣的 消费者");}}}
}

四、Headers 类型交换机

//规则:headers类型的Exchange不依赖于routing key与binding key的匹配规则来路由消息,而是根据发送的消息内容中的headers属性进行匹配。在绑定Queue与Exchange时指定一组键值对以及x-match参数,x-match参数是字符串类型,可以设置为any或者all。如果设置为any,意思就是只要匹配到了headers表中的任何一对键值即可,all则代表需要全部匹配。

生产者

public class HeaderExchange
{public static void Send(){var factory = new ConnectionFactory();factory.HostName = "localhost";//RabbitMQ服务在本地运行factory.UserName = "guest";//用户名factory.Password = "guest";//密码 using (var connection = factory.CreateConnection()){using (var channel = connection.CreateModel()){//声明Headers类型的交换机:HeaderExchangechannel.ExchangeDeclare(exchange: "HeaderExchange", type: ExchangeType.Headers, durable: false, autoDelete: false, arguments: null);channel.QueueDeclare(queue: "HeaderExchangeAllqueue", durable: false, exclusive: false, autoDelete: false, arguments: null);channel.QueueDeclare(queue: "HeaderExchangeAnyqueue", durable: false, exclusive: false, autoDelete: false, arguments: null);Console.WriteLine("生产者准备就绪....");//绑定的时候,需要给arguments 指定一个字典的实例;根据字典中的 { "x-match","all/any"},//如果:{ "x-match","all"}, 发送消息的时候,带的参数列表必须和arguments参数中除了x-match以外,其他的必须都具备才能转发到对应的队列中去;//如果:{ "x-match","any"},发送消息的时候,带的参数列表必须和arguments参数中除了x-match以外,任何一个能够匹配就转发到该队列中去;channel.QueueBind(queue: "HeaderExchangeAllqueue", exchange: "HeaderExchange", routingKey: string.Empty,arguments: new Dictionary<string, object> {{ "x-match","all"},{ "teacher","Richard"},{ "pass","123"}});{string message = "teacher和pass都相同时发送的消息";IBasicProperties props = channel.CreateBasicProperties();props.Headers = new Dictionary<string, object>() {{ "teacher","Richard"},{ "pass","123"}};var body = Encoding.UTF8.GetBytes(message);//基本发布channel.BasicPublish(exchange: "HeaderExchange",routingKey: string.Empty,basicProperties: props,body: body);Console.WriteLine($"消息【{message}】已发送");}{string message = "teacher和pass有一个不相同时发送的消息";var props = channel.CreateBasicProperties();props.Headers = new Dictionary<string, object>() {{ "teacher","Richard"},{ "pass","234"}};var body = Encoding.UTF8.GetBytes(message);channel.BasicPublish(exchange: "HeaderExchange",routingKey: string.Empty,basicProperties: props,body: body);Console.WriteLine($"消息【{message}】已发送");}Console.WriteLine("**************************************************************");{channel.QueueBind(queue: "HeaderExchangeAnyqueue", exchange: "HeaderExchange", routingKey: string.Empty,arguments: new Dictionary<string, object> {{ "x-match","any"},{ "teacher","Richard"},{ "pass","123"},});string msg = "teacher和pass完全相同时发送的消息";var props = channel.CreateBasicProperties();props.Headers = new Dictionary<string, object>() {{ "teacher","Richard"},{ "pass","123"}};var body = Encoding.UTF8.GetBytes(msg);channel.BasicPublish(exchange: "HeaderExchange",routingKey: string.Empty,basicProperties: props,body: body);Console.WriteLine($"消息【{msg}】已发送");}{string msg = "teacher和pass有一个不相同时发送的消息";var props = channel.CreateBasicProperties();props.Headers = new Dictionary<string, object>() {{ "teacher","Richard"},{ "pass","234"}};var body = Encoding.UTF8.GetBytes(msg);channel.BasicPublish(exchange: "HeaderExchange",routingKey: string.Empty,basicProperties: props,body: body);Console.WriteLine($"消息【{msg}】已发送");}}}Console.ReadKey();}
}

如果:{ “x-match”,“all”}, 发送消息的时候,带的参数列表必须和arguments参数中除了x-match以外,其他的必须都具备才能转发到对应的队列中去;

如果:{ “x-match”,“any”},发送消息的时候,带的参数列表必须和arguments参数中除了x-match以外,任何一个能够匹配就转发到该队列中去;

消费者

消费者同前面,因为这种交换机是对发布者的限制

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

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

相关文章

windows系统修改mysql8配置文件,关闭ssl验证

如何寻找配置文件 我的电脑&#xff0c;右键&#xff0c;管理&#xff0c;服务 找到MySQL8 右键&#xff0c;属性 找到配置文件位置 通常情况下的默认路径是&#xff1a; C:\ProgramData\MySQL\MySQL Server 8.0\my.ini 如何关闭SSL验证 打开 my.ini 配置内容如下&#x…

算法:HJ23 删除字符串中出现次数最少的字符

描述 实现删除字符串中出现次数最少的字符&#xff0c;若出现次数最少的字符有多个&#xff0c;则把出现次数最少的字符都删除。输出删除这些单词后的字符串&#xff0c;字符串中其它字符保持原来的顺序。 数据范围&#xff1a;输入的字符串长度满足 1≤n≤20 &#xff0c;保…

【100天精通python】Day7:数据结构_列表 List的创建、删除、访问、遍历、统计、排序、推导等使用

目录 1 列表的创建 2 列表的删除 3 访问列表元素 4 遍历列表 5 添加修改删除列表元素 6 对列表进行统计和计算 7 对列表进行排序 8 列表推导式 9 多维列表 在Python中&#xff0c;列表是一种有序的可变数据类型&#xff0c;用于存储一组元素。 列表使用方括号“[] ”来…

Qt5.14.2下载及安装

1. 下载 https://download.qt.io/archive/qt/5.14/5.14.2/ 由于Qt 自从5.15版本开始&#xff0c;对非商业版本&#xff08;也就是开源版本&#xff09;&#xff0c;不提供已经制作好的离线exe安装包。所以&#xff0c;对于5.15&#xff08;含&#xff09;之后的版本&#xff…

软件智能:aaas系统全部内容 之序 零-AI三部曲 (重新汇总整理)

想法ideal 这次的重新整理是希望作为所有过去整理过和思考过的内容的一个类似词典编纂的工作&#xff0c;将之前的东西打乱以后能挂靠在这个词典的下面。 想法是以“人工智能”的语义为焦点&#xff08;统一行为特征&#xff0c;注1&#xff09;&#xff0c;并将语用作为结构…

Idea 设置类和方法的注释(获取参数)

Idea 添加注释&#xff1a;类注释、方法注释 类注释 方法注释 类注释 File–Setting–Editor–File and Code Templates–Class: 注释模板&#xff1a; /** **description: *author: fqtang*time: ${DATE} ${TIME}* */ 操作截图&#xff1a; 效果&#xff1a; 方法注释 为了…

图数据库Neo4j学习二——cypher基本语法

1命名规范 名称应以字母字符开头&#xff0c;不以数字开头&#xff0c;名称不应包含符号&#xff0c;下划线除外可以很长&#xff0c;最多65535( 2^16 - 1) 或65534字符&#xff0c;具体取决于 Neo4j 的版本名称区分大小写。:PERSON和:Person是:person三个不同的标签&#xff…

Langchain 使用 OpenAI 聊天模型

Langchain 使用 OpenAI 聊天模型 本笔记本介绍了如何开始使用 OpenAI 聊天模型。 示例代码&#xff0c; from langchain.chat_models import ChatOpenAI from langchain.prompts.chat import (ChatPromptTemplate,SystemMessagePromptTemplate,AIMessagePromptTemplate,Human…

Jmeter+Jenkins+Ant自动化持续集成环境搭建

一、安装准备 1.JDK:jdk-8u121-windows-x64 2.jmeter工具&#xff1a;apache-jmeter-2.13 3.ANT工具&#xff1a;apache-ant-1.9.7-bin 4.jenkins工具&#xff1a;jenkins-2.32.2 二、软件安装 1.JDK的安装 >双击JDK安装包&#xff0c;选择安装路径&#xff08;本人是…

详细总结Webpack5的配置和使用

打包工具 使用框架&#xff08;React、Vue&#xff09;&#xff0c;ES6 模块化语法&#xff0c;Less/Sass 等 CSS预处理器等语法进行开发的代码要想在浏览器运行必须经过编译成浏览器能识别的 JS、CSS 等语法&#xff0c;才能运行。 所以需要打包工具帮我们做完这些事。除此之…

3、C# 方法构成

上一节,我们讲述了程序的基本构成。由大到小分别为”解决方案-->项目-->类-->方法“。 这一节,我们讲讲方法。 方法可以说是程序的基本构成单位。假如把方法抽象成点的话,我们可以认为程序是一个树状的结构。树根,就是我们的起点方法,也叫主方法。这一点,基本…

决策树(Decision Tree)

决策树的原理 决策树算法是一种基于树结构的分类和回归算法。它通过对数据集进行递归地分割&#xff0c;构建一个树形模型&#xff0c;用于预测目标变量的值。 决策树的构建过程基于以下原理&#xff1a; 1. 特征选择&#xff1a;选择最佳的特征来进行数据集的分割。常用的…

堆排序与直接选择排序

目录 一、直接选择排序 1.基本思想 2.直接选择排序的特性总结 3.代码实现&#xff1a; 二、堆排序 1. 概念&#xff1a; 2.图像实现&#xff1a; 3.代码实现&#xff1a; 一、直接选择排序 1.基本思想 每一次从待排序的数据元素中选出最小&#xff08;或最大&#xff09…

MySQL多表连接查询练习

准备工作 创建student表 CREATE TABLE student ( id INT(10) NOT NULL UNIQUE PRIMARY KEY , name VARCHAR(20) NOT NULL , sex VARCHAR(4) , birth YEAR, department VARCHAR(20) , address VARCHAR(50) );创建score表 CREATE TABLE score ( id INT(10) NOT …

NetSuite ERP顾问的进阶之路

目录 1.修养篇 1.1“道”是什么&#xff1f;“器”是什么&#xff1f; 1.2 读书这件事儿 1.3 十年计划的力量 1.3.1 一日三省 1.3.2 顾问损益表 1.3.3 阶段课题 2.行为篇 2.1协作 2.2交流 2.3文档管理 2.4时间管理 3.成长篇 3.1概念能力 3.1.1顾问的知识结构 …

大数据学习05-Kafka分布式集群部署

系统环境&#xff1a;centos7 软件版本&#xff1a;jdk1.8、zookeeper3.4.8、hadoop2.8.5 本次实验使用版本 kafka_2.12-3.0.0 一、安装 Kafka官网 将安装包上传至linux服务器上 解压 tar -zxvf kafka_2.12-3.0.0.tgz -C /home/local/移动目录至kafka mv kafka_2.12-3.0…

护城河理论

护城河理论 护城河理论|来自股神巴菲特&#xff0c;是指投资的企业在某一方面的核心竞争力。 模型介绍 在2000年的伯克希尔哈撒韦的年会上&#xff0c;巴菲特说&#xff1a;让我们来把护城河作为一个伟大企业的首要标准&#xff0c;保持它的宽度&#xff0c;保持它不被跨越。我…

听GPT 讲K8s源代码--pkg(五)

在 Kubernetes 中&#xff0c;kubelet 是运行在每个节点上的主要组件之一&#xff0c;它负责管理节点上的容器&#xff0c;并与 Kubernetes 控制平面交互以确保容器在集群中按照期望的方式运行。kubelet 的代码位于 Kubernetes 代码库的 pkg/kubelet 目录下。 pkg/kubelet 目录…

算法-快速排序-java

下面是使用Java实现快速排序的一种方法&#xff1a; public class QuickSort {public static void quickSort(int[] arr, int low, int high) {if (low < high) {// 将数组划分为两个子数组&#xff0c;并获取划分点的索引int pivotIndex partition(arr, low, high);// 递…

数学建模-分类模型 Fisher线性判别分析

论文中1. 判别分析系数 2. 分类结果 多分类问题 勾选内容和上面一样