1.首先是创建项目

在一个父工程 mq_demo 的基础上建立两个子模块,生产者模块publisher,消费者模块 consumer
创建项目:
在这里插入图片描述
建立成功:
在这里插入图片描述
删除多余文件
在这里插入图片描述
创建子模块1:publisher(生产者模块)
右键-----new ----module
在这里插入图片描述
选中Java,填写publisher,选中maven,确认父模块
在这里插入图片描述
创建成功
在这里插入图片描述
同理:创建子模块2:consumer(消费者模式)
在这里插入图片描述
至此:项目创建完毕

2.进行基本配置(pom.xml、application.yml)

引入依赖:父模块引入依赖,子模块共享父模块依赖

pom.xml

<dependencies><!--AMQP依赖,包含 rabbitmq --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-amqp</artifactId></dependency><!--单元测试--><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.13.2</version><scope>test</scope></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter</artifactId></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><optional>true</optional></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency></dependencies>

application.yml

logging:pattern:dateformat: yyyy-MM-dd HH:mm:ss.SSSlevel:mq.listener:  debug
spring:rabbitmq:host: 127.0.0.1port: 5672username: guestpassword: guestvirtual-host: /

结构图:
在这里插入图片描述
建立具体的包结构,以及要用的一些类
在这里插入图片描述
消费者启动类:ConsumerApplication.class

@SpringBootApplication
public class ConsumerApplication {public static void main(String[] args) {SpringApplication.run(ConsumerApplication.class, args);}}

生产者启动类:PublisherApplication.class

@SpringBootApplication
public class PublisherApplication {public static void main(String[] args) {org.springframework.boot.SpringApplication.run(PublisherApplication.class, args);}
}

消费者监听类:SpringRabbitListerner.class

@Component
public class SpringRabbitListerner {@RabbitListener(queues = "queue.simple")public void listenSimpleQueueMessage(String msg){System.out.println("简单模式-消费者消费消息:"+msg);}
}

生产者启动类:SpringAmqpTest.class

@ExtendWith(SpringExtension.class)
@SpringBootTest
public class SpringAmqpTest {@Autowiredprivate RabbitTemplate  rabbitTemplate;@Testpublic void testSendSimpleMessage() {String simpleQueue = "queue.simple";String message = "hello world";rabbitTemplate.convertAndSend(simpleQueue,message);}
}

做到这里,就已经可以进行mq的消息进行发送和获取了。

3.Spring AMQP的五种工作模式

生产者启动类:SpringAmqpTest.class

@ExtendWith(SpringExtension.class)
@SpringBootTest
public class SpringAmqpTest {@Autowiredprivate RabbitTemplate  rabbitTemplate;@Testpublic void testSendSimpleMessage() {String simpleQueue = "queue.simple";String message = "hello world";rabbitTemplate.convertAndSend(simpleQueue,message);}@Testpublic void testSendWorkQueue(){String workQueue = "queue.work";for(int i=1 ;i<=10;i++){String message = "hello world.."+i;rabbitTemplate.convertAndSend(workQueue,message);}}@Testpublic void testSendFanout(){String fanoutExchange = "amq.fanout";String message = "hello world fanout..";rabbitTemplate.convertAndSend(fanoutExchange,"",message);}@Testpublic void testSendDirect(){String directExchange = "amq.direct";String message = "hello world direct..";rabbitTemplate.convertAndSend(directExchange,"red",message);}}

消费者监听类:SpringRabbitListerner.class

@Component
public class SpringRabbitListerner {@RabbitListener(queues = "queue.simple")public void listenSimpleQueueMessage(String msg){System.out.println("简单模式-消费者消费消息:"+msg);}@RabbitListener(queues = "queue.work")public void listenWorkQueueMessage1(String msg){System.out.println("工作模式-消费者消费消息:"+msg);}@RabbitListener(queues = "queue.work")public void listenWorkQueueMessage2(String msg){System.out.println("工作模式-消费者消费消息2:"+msg);}@RabbitListener(queues = "queue.fanout1")public  void listenFanoutQueueMessage1(String msg){System.out.println("发布订阅模式-消费者1消费消息:"+msg);}@RabbitListener(queues = "queue.fanout2")public  void listenFanoutQueueMessage2(String msg){System.out.println("发布订阅模式-消费者2消费消息:"+msg);}@RabbitListener(queues = "queue.direct1")public void listenDirectQueueMessage(String msg){System.out.println("路由模式-消费者消费消息:"+msg);}@RabbitListener(queues = "queue.direct2")public void listenTopicQueueMessage1(String msg){System.out.println("路由模式-消费者1消费消息:"+msg);}}

所用到的配置类:
主要是建立交换机、建立队列、绑定交换机和队列关系的
订阅者模式

@Configuration
public class FunoutConfig {@Beanpublic FanoutExchange fanoutExchange() {return new FanoutExchange("amq.fanout");}@Beanpublic Queue  queue1() {return new Queue("queue.fanout1");}@Beanpublic Queue   queue2() {return new Queue("queue.fanout2");}@Beanpublic Binding binding1(Queue queue1, FanoutExchange fanoutExchange) {return BindingBuilder.bind(queue1).to(fanoutExchange);}@Beanpublic Binding binding2(Queue queue2, FanoutExchange fanoutExchange) {return BindingBuilder.bind(queue2).to(fanoutExchange);}}

路由模式

@Configuration
public class DirectConfig {@Beanpublic DirectExchange directExchange(){return new DirectExchange("amq.direct");}@Beanpublic Queue directQueue1(){return new Queue("queue.direct1");}@Beanpublic Queue directQueue2(){return new Queue("queue.direct2");}@Beanpublic Binding  directBinding1(Queue queue1, DirectExchange directExchange){return BindingBuilder.bind(queue1).to(directExchange).with("yellow");}@Beanpublic Binding  directBinding2(Queue queue2, DirectExchange directExchange){return BindingBuilder.bind(queue2).to(directExchange).with("red");}}

2025-6-13

4.mq的高级特性:

1、消息的安全性问题----生产者、消费者确认、mq持久化
2、延迟队列----做定时任务
3、惰性队列----处理数据积压
3、模拟集群----处理单点崩溃

4.1 消息队列的安全性问题:

	生产者确认:生产者发送消息---到交换机+到队列---返回ack给mq生产者发送消息---没到交换机---返回nack给mq生产者发送消息---到交换机,没到队列---返回ack,触发回调

模块剥离:(代码部分)
1.生产者确认机制
yml配置:

	logging:pattern:dateformat: yyyy-MM-dd HH:mm:ss.SSSlevel:com.example.demo: debug
spring:rabbitmq:host: 127.0.0.1port: 5672username: guestpassword: guestvirtual-host: /#springAMQP 实现生产者确认publisher-confirm-type: correlated #simple 同步等待confirm结果,直到超时;correlated:异步回调,定义confirmcollback,MQ返回结果时,会回调ConfirmCallbackpublisher-returns: true # 开启publish-return 功能,同样是基于callback机制,不过是定义ReturnCallbacktemplate:mandatory: true # 定义消息路由失败时的策略。true,则调用ReturnCallback;false则直接丢弃消息

消息到交换机—ack的回应

package mq.demo;import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.UUID;@RunWith(SpringRunner.class)
@SpringBootTest
@Slf4j
public class SpringPublisherTest {@Autowiredprivate RabbitTemplate rabbitTemplate;@Testpublic void simpleSendMessage(){//1.准备消息String  msg = "hello spring amqp";//2.准备CorrelationDate//2.1消息idCorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString());//2.2准备ConfirmCallbackrabbitTemplate.setConfirmCallback((correlationData1, ack, cause) -> {if (ack) {log.info("消息确认成功,ID: {}", correlationData1 != null ? correlationData1.getId() : "无ID");} else {log.error("消息确认失败,ID: {}, 原因: {}", correlationData1 != null ? correlationData1.getId() : "无ID", cause);}});rabbitTemplate.convertAndSend("amq.direct","yellow",msg,correlationData);}
}

消息到了交换机ack----消息没到队列 ,路由发送失败—触发回调

package mq.config;import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Configuration;@Slf4j
@Configuration
public class CommonConfig implements ApplicationContextAware {@Overridepublic void setApplicationContext(ApplicationContext applicationContext) throws BeansException {//获取rabbitmq对象RabbitTemplate rabbitTemplate = applicationContext.getBean(RabbitTemplate.class);//配置 ReturnCallback 当发送者发送消息到MQ,MQ返回失败,会调用此方法(记住;是路由发送失败)rabbitTemplate.setReturnsCallback(msg -> {//记录日志log.error("消息发送到队列失败!" +"响应码:{}" +"失败原因:{}" +"交换机:{}" +"路由key:{}",msg.getReplyCode(),msg.getReplyText(),msg.getExchange(),msg.getRoutingKey());});}
}

持久化:解决mq宕机造成的交换机丢失、队列丢失、消息丢失
消费者确认:
消费者收到消息—消费者处理消息—消费者返回ack
消费者收到消息—消费者处理消息—消费者应该返回nack
针对第二种情况:衍生出消费者确认机制
1.none,mq发完消息,自动删除,不等ack
2.手动处理,try-catch,然后自己捕捉异常,捕捉到了返回给mq服务器nack
3.自动处理,auto;系统自己捕捉异常,然后返回nack、
针对消费者确认机制:可能出现循环的问题
解决办法:配上retry机制,设定本地重试
1.消费者自己处理,耗尽次数,自动放弃消息
2.耗尽次数,返还消息给mq队列,循环
3.耗尽次数,将消息送到error交换机
模块剥离:(代码部分)

logging:pattern:dateformat: yyyy-MM-dd HH:mm:ss.SSSlevel:mq.listener:  debug
spring:rabbitmq:host: 127.0.0.1port: 5672username: guestpassword: guestvirtual-host: /listener:simple:prefetch: 1#acknowledge-mode: none  #关闭ack,MQ假定消费者获取消息后会成功处理。因此消息投递后立即被删除acknowledge-mode: auto #自动ack模式,由spring检测listener代码是否出现异常,没有异常则返回ack,有异常则返回nack#acknowledge-mode: manual #手动ack,需要在业务代码结束后,调用api发送ackretry:enabled: true # 开启消费者失败重试initial-interval: 1000ms  #初试的失败等待时长为1秒multiplier: 3 #  失败重试的间隔倍数(下次失败的等待时长倍数),下次等待时长 = multiplier * last-intervalmax-attempts: 4 #  最大失败重试次数

配置error交换机,次数耗尽,就把消息送到error交换机,

package mq.demo.config;import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.retry.MessageRecoverer;
import org.springframework.amqp.rabbit.retry.RepublishMessageRecoverer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;@Configuration
public class ErrorMessageConfig {@Beanpublic DirectExchange  errorMessageExchange() {return new DirectExchange("error.direct");}@Beanpublic Queue errorMessageQueue() {return new Queue("error.queue");}@Beanpublic Binding errorMessageBinding() {return new Binding("error.queue",Binding.DestinationType.QUEUE,"error.direct","error",null);}@Beanpublic MessageRecoverer republicMessageRecoverer(RabbitTemplate rabbitTemplate) {return new RepublishMessageRecoverer(rabbitTemplate, "error.direct", "error");}}

4.2.延迟队列:

初始死信交换机:当一个队列中的消息满足下列情况之一时,可以成为死信(dead letter)
1、消费者使用basic.reject或basic.nack声明消费失败,并且消息的requeue的参数设置为false
2、消息是一个过期消息,超时无人消费
3、要投递的队列消息堆积满了,最早的消息可能成为死信
如果该队列配置了dead-letter-exchange属性,指定了一个交换机,那么队列中的死信就会投递到这个交换机,这个交换机称为死信交换机(Dead Letter Exchange,简称DLX)。
死信交换机的运行原理

在这里插入图片描述
小总结(和上面的有所重复)
在这里插入图片描述
TTL:延迟队列
TTL,也就是Time-To-Live。如果一个队列中的消息TTL结束仍未消费,则会变成死信,ttl超时分为两种情况
1、消息所在的队列设置了存活时间
2、消息本身设置了存活时间
TTL的运行原理:如图
在这里插入图片描述

模块剥离:(代码部分)
首先绑定死信交换机和死信队列,并设置消费者去消费消息
在这里插入图片描述

  @RabbitListener(bindings = @QueueBinding(value = @Queue(name = "dl.queue"),exchange = @Exchange(value = "dl.direct"),//默认是direct持久化key = "dl"))public void listenDlQueue(String msg){log.info("测试死信队列,接收到了延迟消息,消息内容为:{}"+msg);}

然后建立延迟交换机和延迟队列的绑定,在延迟队列上再绑定死信交换机
在这里插入图片描述
附上代码:

package mq.demo.config;import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;@Configuration
public class TTLMessage {@Beanpublic DirectExchange ttlExchange() {return new DirectExchange("ttl.direct");}@Beanpublic Queue ttlQueue() {return QueueBuilder.durable("ttl.queue").ttl(10000).deadLetterExchange("dl.direct").deadLetterRoutingKey("dl").build();}@Beanpublic Binding bindingTTLQueue(DirectExchange ttlExchange, Queue ttlQueue) {return BindingBuilder.bind(ttlQueue).to(ttlExchange).with("ttl");}    
}

发送消息:代码

package mq.demo;import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageBuilder;
import org.springframework.amqp.core.MessageDeliveryMode;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;import java.nio.charset.StandardCharsets;
import java.util.UUID;@RunWith(SpringRunner.class)
@SpringBootTest
@Slf4j
public class SpringPublisherTest {@Autowiredprivate RabbitTemplate rabbitTemplate;@Testpublic void testTTLMessage(){//1.准备消息Message message = MessageBuilder.withBody("hello ttl amqp".getBytes(StandardCharsets.UTF_8))//.setExpiration("5000") 设置延迟时间.setDeliveryMode(MessageDeliveryMode.PERSISTENT).build();//2.发送消息rabbitTemplate.convertAndSend("ttl.direct","ttl",message);}
}

mq呈现的状态和idea控制台的输出结果为:
publisher:生产者发送消息
ttl:延迟队列首先收到消息
在这里插入图片描述
然后,再指定时间没有人消息该消息,消息自动转为死信,并进入指定的延迟队列
在这里插入图片描述
然后被idea消费,在idea控制台进行打印
在这里插入图片描述
评价:就是我这里的思维逻辑是优点混乱的
1.我发送消息的前提是我mq里面得有已经建好的队列和交换机以及它们之间的绑定关系,所以我应该是先启动消费者的启动类,将这些交换机和队列存到bean工厂里面去。形成对象,并且在mq里面呈现出来
2.我运行了很多次,才弄好了,
3.我项目如果是就是一个单一的项目,不涉及微服务,不分那么多微服务模块,这个时候我应该怎么写。

4.3 惰性队列

消息堆积问题:1.当生产者发送消息的速度超过了消费者处理消息的速度,就会导致队列中的消息堆积,直到队列存储消息达到上限。最早接收到的消息,可能成为死信,会被丢弃,这就是消息堆积问题。2.解决消息堆积有三种思路:1、增加更多消费者,提高消费者消费速度(就是5种模式的第二种--工作者模式work)2、在消费者内开启线程池加快消息处理速度3、扩大队列容积,提高堆积上限3.惰性队列特征:1、接收到消息后直接存入磁盘而非内存2、消费者要消费消息时才会从磁盘中读取并加载到内存3、支持数百万条的消息存储

惰性队列
两种声明方式:
1、基于@Bean

package mq.demo.config;import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.QueueBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;@Configuration
public class LazyConfig {@Beanpublic Queue lazyQueue() {return QueueBuilder.durable("lazy.queue").lazy().build();}@Beanpublic Queue normalQueue() {return QueueBuilder.durable("normal.queue").build();}}

2、基于注解(略)
给建立好的两个队列各发送100万条信息
附上代码:

 @Testpublic void testLazyMessage(){//2.发送消息for (int i = 1; i <= 1000000; i++){//1.准备消息Message message = MessageBuilder.withBody("hello lazy amqp".getBytes(StandardCharsets.UTF_8)).setDeliveryMode(MessageDeliveryMode.NON_PERSISTENT).build();rabbitTemplate.convertAndSend("lazy.queue",message);}}@Testpublic void testNormalMessage(){//2.发送消息for (int i = 1; i <= 1000000; i++){//1.准备消息Message message = MessageBuilder.withBody("hello lazy amqp".getBytes(StandardCharsets.UTF_8)).setDeliveryMode(MessageDeliveryMode.NON_PERSISTENT).build();rabbitTemplate.convertAndSend("normal.queue",message);}}

在这里插入图片描述
lazy队列的话,他是直接发送到磁盘的,不进内存
在这里插入图片描述
normal队列的话,进内存大概3万条,超过了就刷进磁盘
(下面这张图数据里没有pageout)数据有些不准确
normal的话,应该是in memory进内存一部分,超过了就进磁盘
在这里插入图片描述

4.4 集群模式:暂时略

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

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

相关文章

DAY 31 文件的规范拆分和写法

浙大疏锦行 今日的示例代码包含2个部分 notebook文件夹内的ipynb文件&#xff0c;介绍下今天的思路项目文件夹中其他部分&#xff1a;拆分后的信贷项目&#xff0c;学习下如何拆分的&#xff0c;未来你看到的很多大项目都是类似的拆分方法 知识点回顾 规范的文件命名规范的文件…

EtherCAT至TCP/IP异构网络互联:施耐德M580 PLC对接倍福CX5140解决方案

一、项目背景与需求 某智能工厂致力于打造高度自动化的生产流水线&#xff0c;其中部分核心设备采用EtherCAT协议进行通信&#xff0c;以实现高速、高精度的控制&#xff0c;例如基于EtherCAT总线的倍福&#xff08;Beckhoff&#xff09;CX5140PLC&#xff0c;它能够快速响应设…

[学习] FIR多项滤波器的数学原理详解:从多相分解到高效实现(完整仿真代码)

FIR多项滤波器的数学原理详解&#xff1a;从多相分解到高效实现 文章目录 FIR多项滤波器的数学原理详解&#xff1a;从多相分解到高效实现引言一、FIR滤波器基础与多相分解原理1.1 FIR滤波器数学模型1.2 多相分解的数学推导1.3 多相分解的物理意义 二、插值应用中的数学原理2.1…

Java并发编程实战 Day 22:高性能无锁编程技术

【Java并发编程实战 Day 22】高性能无锁编程技术 文章简述 在高并发场景下&#xff0c;传统的锁机制&#xff08;如synchronized、ReentrantLock&#xff09;虽然能够保证线程安全&#xff0c;但在高竞争环境下容易引发性能瓶颈。本文深入探讨无锁编程技术&#xff0c;重点介绍…

打破语言壁垒!DHTMLX Gantt 与 Scheduler 文档正式上线中文等多语言版本!

你还在为英文技术文档望而却步吗&#xff1f;现在好消息来了&#xff01;DHTMLX 团队宣布&#xff0c;其两款明星组件——DHTMLX Gantt&#xff08;甘特图&#xff09;与 DHTMLX Scheduler&#xff08;日程排程器&#xff09;的官方文档&#xff0c;现已全面支持中文、德语、韩…

无监督 vs 有监督的本质区别

一、无监督 vs 有监督的本质区别 1. 无监督学习 定义&#xff1a;数据中没有人为标注的 “正确答案”&#xff08;如类别标签、目标值&#xff09;&#xff0c;模型需自己发现数据中的模式。任务目标&#xff1a;学习数据的分布规律、结构或生成逻辑。例子&#xff1a; 文本续…

【Linux】初见,进程概念

前言&#xff1a; 上文我们讲到了Linux下的第一个程序&#xff1a;进度条 【Linux】LInux下第一个程序&#xff1a;进度条-CSDN博客 本文我们来讲一讲Linux中下一个非常重要的东西&#xff1a;进程 1.冯诺依曼体系结构 我们所见的大部分计算机都是遵循的冯诺依曼体系结构…

Linux进程间通信(IPC)详解:从入门到理解

引言 作为一名C开发初学者&#xff0c;理解Linux下的进程间通信&#xff08;Inter-Process Communication&#xff0c;简称IPC&#xff09;机制是非常重要的一步。本文将用通俗易懂的语言&#xff0c;配合直观的图示&#xff0c;帮助你理解Linux进程间通信的基本概念和各种实现…

SQL进阶之旅 Day 27:存储过程与函数高级应用

【SQL进阶之旅 Day 27】存储过程与函数高级应用 文章简述 在数据库开发中&#xff0c;存储过程和函数是实现复杂业务逻辑、提高代码复用性和提升系统性能的重要工具。本文作为“SQL进阶之旅”系列的第27天&#xff0c;深入探讨存储过程与函数的高级应用&#xff0c;涵盖其设计…

泰国零售巨头 CJ Express 借助 SAP 内存数据库实现高效数据管理

泰国 CJ Express 运用 SAP 内存数据库有效控制数据增长案例 “Datavard Outboard 操作简便、配置轻松&#xff0c;我们得以在生产系统上完成数据归档&#xff0c;成功将约 730GB 数据迁移至 Hadoop 集群。”——K. Jak&#xff0c;J Express 技术服务经理 关于 CJ Express …

ImageSharp.Web 使用指南:高效处理ASP.NET Core中的图像

文章目录 前言一、ImageSharp.Web简介二、安装与配置1. 安装NuGet包2. 基本配置3. 高级配置 三、核心功能与使用示例1. 基本图像处理2. 处理模式详解3. 自定义处理命令 四、缓存策略1. 物理文件系统缓存2. 分布式缓存3. 自定义缓存 五、性能优化建议六、常见问题解决1. 图像处理…

使用R进行数字信号处理:婴儿哭声分析深度解析

音频信号处理将原始声音数据转化为有意义的洞见&#xff0c;适用于语音分析、生物声学和医学诊断等领域。使用R语言&#xff0c;我们可以处理音频文件、可视化频率内容&#xff0c;并生成如声谱图等详细图表。本指南将展示如何使用R包tuneR、seewave和rpanel分析婴儿哭声音频文…

【环境配置】解决linux每次打开终端都需要source .bashrc文件的问题

解决方法&#xff1a; cd vim .bash_profile输入下面内容后 :wq 保存并退出 # .bash_profileif [ -f ~/.bashrc ]; then. ~/.bashrc fi 参考链接&am…

ResizeObserver的错误

为什么会存在ResizeObserver错误 ResizeObserver loop completed with undelivered notifications. ResizeObserver用于监听元素content size和border size的变化。但是元素的变化和监听可能会导致循环触发&#xff0c;例如有元素A&#xff0c;监听元素A尺寸变化后将元素A的宽…

[k8s]--exec探针详细解析

在 Kubernetes 中&#xff0c;exec 探针是一种通过 在容器内执行命令 来检测容器健康状态的机制。它的核心逻辑是&#xff1a;执行命令后&#xff0c;若命令返回值为 0&#xff08;表示成功&#xff09;&#xff0c;则认为容器健康&#xff1b;否则认为不健康。 一、exec 探针的…

偶数项收敛半径

&#x1f9e0; 背景&#xff1a;幂级数与收敛半径 一个幂级数&#xff08;power series&#xff09;&#xff1a; ∑ n 0 ∞ a n x n \sum_{n0}^{\infty} a_n x^n n0∑∞​an​xn 其收敛半径 R R R 表示该级数在哪些 x x x 的取值范围内收敛。其计算公式&#xff1a; 1 R …

从0开始学习语言模型--Day01--亲自构筑语言模型的重要性

在如今这个时代&#xff0c;人工智能俨然已经成了一个大家耳熟能详的词汇。随着技术的发展&#xff0c;它在不断地降低计算机领域一些工作的门槛&#xff0c;甚至有时候我们能看到一个可能六年前还需要从头开始学习的职业&#xff0c;现在只需要能掌握一个专属的小模型就可以拥…

【量化】策略交易之动量策略(Momentum)

【量化】策略交易之动量策略&#xff08;Momentum&#xff09; 一、动量策略&#xff08;Momentum Strategy&#xff09;原理 &#x1f449;&#x1f3fb; 核心思想&#xff1a; 强者恒强&#xff0c;弱者恒弱。 动量策略认为&#xff0c;过去一段时间涨得多的资产&#xff0c…

Cesium快速入门到精通系列教程九:Cesium 中高效添加和管理图标/标记的标准方式​​

Cesium中通过 ​​Primitive 高效添加 ​​点、线、多边形、圆、椭圆、球、模型​​ 等地理要素&#xff0c;以下是各类地理要素的高效添加方式&#xff1a; 一、公告板 1. 创建 BillboardCollection 并添加到场景​ const billboards viewer.scene.primitives.add(new Ces…

volka烹饪常用英语

1. 视频开场与主题介绍 Today, we are going to learn English while cooking. Fire. In this video, I’m going to continue to teach you the 3,000 most common English words that will allow you to understand 95% of spoken English. And we are going to be preparin…