RabbitMQ的DLX(Dead-Letter-Exchange 死信交换机,死信交换器,死信邮箱)(重要)
RabbitMQ的DLX
- 1、RabbitMQ死信队列
- 2、代码示例
- 2.1、队列过期
- 2.1.1、配置类RabbitConfig(关键代码)
- 2.1.2、业务类MessageService
- 2.1.3、配置文件application.yml
- 2.1.4、启动类
- 2.1.5、配置文件
- 2.1.6、测试
- 2.2、消息过期
- 2.2.1、配置类RabbitConfig
- 2.2.2、业务类MessageService(关键代码)
- 2.2.3、配置文件application.yml
- 2.2.4、启动类同上
- 2.2.5、配置文件同上
- 2.2.6、测试
- 2.3、队列达到最大长度(先入队的消息会被发送到DLX)
- 2.3.1、配置类RabbitConfig(关键代码)
- 2.3.2、业务类MessageService(关键代码)
- 2.3.3、配置文件application.yml
- 2.3.4、启动类同上
- 2.3.5、配置文件pom.xml同上
- 2.3.6、测试
- 2.4、消费者拒绝消息不进行重新投递
- 2.4.1、生产者
- 2.4.1.1、生产者application.yml
- 2.4.1.2、生产者发送消息
- 2.4.1.3、生产者配置类
- 2.4.2、消费者
- 2.4.2.1、消费者application.yml 启动手动确认
- 关键配置
- 2.4.2.2、消费者接收消息
- 关键代码
- 2.4.3、测试
1、RabbitMQ死信队列
RabbitMQ死信队列也有叫 死信交换机、死信邮箱等说法。
DLX: Dead-Letter-Exchange 死信交换器,死信邮箱。
1-2、生产者发送一个消息到正常交换机
2-4、正常交换机接收到消息发送到正常队列
4、正常队列设置了队列过期时间,超时消息会自动删除
4-6、原本过期自动删除的消息发送到了死信交换机
6-8、死信交换机将消息发送到了死信队列
如上情况下一个消息会进入DLX(Dead Letter Exchange)死信交换机。
2、代码示例
2.1、队列过期
2.1.1、配置类RabbitConfig(关键代码)
package com.power.config;import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;import java.util.HashMap;
import java.util.Map;@Configuration
public class RabbitConfig {@Value("${my.exchangeNormalName}")private String exchangeNormalName;@Value("${my.queueNormalName}")private String queueNormalName;@Value("${my.exchangeDlxName}")private String exchangeDlxName;@Value("${my.queueDlxName}")private String queueDlxName;/*** 正常交换机* @return*/@Beanpublic DirectExchange normalExchange(){return ExchangeBuilder.directExchange(exchangeNormalName).build();}/*** 正常队列* @return*/@Beanpublic Queue normalQueue(){Map<String, Object> arguments = new HashMap<>();arguments.put("x-message-ttl",20000);//设置队列的过期时间为20秒//重点:设置这两个参数arguments.put("x-dead-letter-exchange",exchangeDlxName); //设置队列的死信交换机arguments.put("x-dead-letter-routing-key","error");//设置死信路由key,要跟死信交换机和死信队列绑定的路由key一致return QueueBuilder.durable(queueNormalName).withArguments(arguments) //设置队列的过期时间.build();}/*** 正常交换机和正常队列绑定* @param normalExchange* @param normalQueue* @return*/@Beanpublic Binding bingNormal(DirectExchange normalExchange,Queue normalQueue){return BindingBuilder.bind(normalQueue).to(normalExchange).with("order");}/*** 死信交换机* @return*/@Beanpublic DirectExchange dlxExchange(){return ExchangeBuilder.directExchange(exchangeDlxName).build();}/*** 死信队列* @return*/@Beanpublic Queue dlxQueue(){return QueueBuilder.durable(queueDlxName).build();}/*** 死信交换机和死信队列绑定* @param dlxExchange* @param dlxQueue* @return*/@Beanpublic Binding bindDlx(DirectExchange dlxExchange,Queue dlxQueue){return BindingBuilder.bind(dlxQueue).to(dlxExchange).with("error");}
}
2.1.2、业务类MessageService
package com.power.service;import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageBuilder;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service;import javax.annotation.Resource;
import java.util.Date;@Service
@Slf4j
public class MessageService {@Resourceprivate RabbitTemplate rabbitTemplate;@Beanpublic void sendMsg(){Message message = MessageBuilder.withBody("hello world".getBytes()).build();rabbitTemplate.convertAndSend("exchange.normal.a","order",message);log.info("消息发送完毕,发送时间是:"+new Date());}
}
2.1.3、配置文件application.yml
server:port: 8080
spring:application:name: dlx-test01rabbitmq:host: 你的服务器IPport: 5672username: 你的账号password: 你的密码virtual-host: powermy:exchangeNormalName: exchange.normal.a #正常交换机queueNormalName: queue.normal.a #正常队列,没有消费组,设置过期时间exchangeDlxName: exchange.dlx.a #死信交换机queueDlxName: queue.dlx.a #死信队列
2.1.4、启动类
package com.power;import com.power.service.MessageService;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;import javax.annotation.Resource;@SpringBootApplication
public class Application implements ApplicationRunner {@Resourceprivate MessageService messageService;public static void main(String[] args) {SpringApplication.run(Application.class);}@Overridepublic void run(ApplicationArguments args) throws Exception {messageService.sendMsg();}
}
2.1.5、配置文件
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.power</groupId><artifactId>rabbit_06_dlx01</artifactId><version>1.0-SNAPSHOT</version><name>rabbit_06_dlx01</name><properties><maven.compiler.source>8</maven.compiler.source><maven.compiler.target>8</maven.compiler.target><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding></properties><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.6.13</version><relativePath/></parent><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>1.18.24</version></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-amqp</artifactId></dependency></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build></project>
2.1.6、测试
启动程序,发送消息:

消息会先被发送到正常队列queue.normal.a中,超时未被消费,
则消息会被发送到死信队列queue.dlx.a 中

2.2、消息过期
2.2.1、配置类RabbitConfig
package com.power.config;import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;import java.util.HashMap;
import java.util.Map;@Configuration
public class RabbitConfig {@Value("${my.exchangeNormalName}")private String exchangeNormalName;@Value("${my.queueNormalName}")private String queueNormalName;@Value("${my.exchangeDlxName}")private String exchangeDlxName;@Value("${my.queueDlxName}")private String queueDlxName;/*** 正常交换机* @return*/@Beanpublic DirectExchange normalExchange(){return ExchangeBuilder.directExchange(exchangeNormalName).build();}/*** 正常队列* @return*/@Beanpublic Queue normalQueue(){Map<String, Object> arguments = new HashMap<>();//重点:设置这两个参数//设置队列的死信交换机arguments.put("x-dead-letter-exchange",exchangeDlxName);//设置死信路由key,要跟死信交换机和死信队列绑定的路由key一致arguments.put("x-dead-letter-routing-key","error");return QueueBuilder.durable(queueNormalName).withArguments(arguments) //设置队列的过期时间.build();}/*** 正常交换机和正常队列绑定* @param normalExchange* @param normalQueue* @return*/@Beanpublic Binding bingNormal(DirectExchange normalExchange,Queue normalQueue){return BindingBuilder.bind(normalQueue).to(normalExchange).with("order");}/*** 死信交换机* @return*/@Beanpublic DirectExchange dlxExchange(){return ExchangeBuilder.directExchange(exchangeDlxName).build();}/*** 死信队列* @return*/@Beanpublic Queue dlxQueue(){return QueueBuilder.durable(queueDlxName).build();}/*** 死信交换机和死信队列绑定* @param dlxExchange* @param dlxQueue* @return*/@Beanpublic Binding bindDlx(DirectExchange dlxExchange,Queue dlxQueue){return BindingBuilder.bind(dlxQueue).to(dlxExchange).with("error");}
}
2.2.2、业务类MessageService(关键代码)
package com.power.service;import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageBuilder;
import org.springframework.amqp.core.MessageProperties;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service;import javax.annotation.Resource;
import java.util.Date;@Service
@Slf4j
public class MessageService {@Resourceprivate RabbitTemplate rabbitTemplate;@Beanpublic void sendMsg(){try {MessageProperties messageProperties = new MessageProperties();//设置单条消息的过期时间,单位为毫秒,数据类型为字符串messageProperties.setExpiration("20000");Message message = MessageBuilder.withBody("hello world".getBytes()).andProperties(messageProperties).build();rabbitTemplate.convertAndSend("exchange.normal.02","order",message);}catch (Exception e){e.printStackTrace();log.info("消息发送失败:"+new Date());}log.info("消息发送完毕,发送时间是:"+new Date());}
}
2.2.3、配置文件application.yml
server:port: 8080
spring:application:name: dlx-test01rabbitmq:host: 你的服务器IPport: 5672username: 你的账号password: 你的密码virtual-host: powermy:exchangeNormalName: exchange.normal.02 #正常交换机queueNormalName: queue.normal.02 #正常队列,没有消费组,设置过期时间exchangeDlxName: exchange.dlx.02 #死信交换机queueDlxName: queue.dlx.02 #死信队列
2.2.4、启动类同上
2.2.5、配置文件同上
2.2.6、测试
启动程序发送消息

登录rabbitmq后台:
消息先进入正常队列queue.normal.02中,超时未消费,
消息超过过期时间,则进入queue.dlx.02死信队列

2.3、队列达到最大长度(先入队的消息会被发送到DLX)
2.3.1、配置类RabbitConfig(关键代码)
package com.power.config;import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;import java.util.HashMap;
import java.util.Map;@Configuration
public class RabbitConfig {@Value("${my.exchangeNormalName}")private String exchangeNormalName;@Value("${my.queueNormalName}")private String queueNormalName;@Value("${my.exchangeDlxName}")private String exchangeDlxName;@Value("${my.queueDlxName}")private String queueDlxName;/*** 正常交换机* @return*/@Beanpublic DirectExchange normalExchange(){return ExchangeBuilder.directExchange(exchangeNormalName).build();}/*** 正常队列* @return*/@Beanpublic Queue normalQueue(){Map<String, Object> arguments = new HashMap<>();//设置队列的最大长度arguments.put("x-max-length",5);//重点:设置这两个参数//设置队列的死信交换机arguments.put("x-dead-letter-exchange",exchangeDlxName);//设置死信路由key,要跟死信交换机和死信队列绑定的路由key一致arguments.put("x-dead-letter-routing-key","error");return QueueBuilder.durable(queueNormalName).withArguments(arguments) //设置队列的参数.build();}/*** 正常交换机和正常队列绑定* @param normalExchange* @param normalQueue* @return*/@Beanpublic Binding bingNormal(DirectExchange normalExchange,Queue normalQueue){return BindingBuilder.bind(normalQueue).to(normalExchange).with("order");}/*** 死信交换机* @return*/@Beanpublic DirectExchange dlxExchange(){return ExchangeBuilder.directExchange(exchangeDlxName).build();}/*** 死信队列* @return*/@Beanpublic Queue dlxQueue(){return QueueBuilder.durable(queueDlxName).build();}/*** 死信交换机和死信队列绑定* @param dlxExchange* @param dlxQueue* @return*/@Beanpublic Binding bindDlx(DirectExchange dlxExchange,Queue dlxQueue){return BindingBuilder.bind(dlxQueue).to(dlxExchange).with("error");}
}
2.3.2、业务类MessageService(关键代码)
package com.power.service;import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageBuilder;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service;import javax.annotation.Resource;
import java.util.Date;@Service
@Slf4j
public class MessageService {@Resourceprivate RabbitTemplate rabbitTemplate;@Beanpublic void sendMsg(){for (int i = 1; i < 8; i++) {String msg = "hello world "+ i;Message message = MessageBuilder.withBody(msg.getBytes()).build();rabbitTemplate.convertAndSend("exchange.normal.03","order",message);log.info("消息发送完毕,发送时间是:"+new Date());}}
}
2.3.3、配置文件application.yml
server:port: 8080
spring:application:name: dlx-test01rabbitmq:host: 你的服务器IPport: 5672username: 你的账号password: 你的密码virtual-host: powermy:exchangeNormalName: exchange.normal.03 #正常交换机queueNormalName: queue.normal.03 #正常队列,没有消费组,设置过期时间exchangeDlxName: exchange.dlx.03 #死信交换机queueDlxName: queue.dlx.03 #死信队列
2.3.4、启动类同上
2.3.5、配置文件pom.xml同上
2.3.6、测试
启动项目,发送消息

登录rabbitmq后台:
两条消息进入死信队列
查看消息发现,是前两条消息进入了死信队列,


2.4、消费者拒绝消息不进行重新投递
消费者从正常的队列接收消息,但是消费者对消息不进行确认,并且不对消息进行重新投递,此时消息就进入死信队列。
2.4.1、生产者

2.4.1.1、生产者application.yml
server:port: 8080
spring:application:name: dlx-test04rabbitmq:host: 你的服务器IPport: 5672username: 你的账号password: 你的密码virtual-host: powermy:exchangeNormalName: exchange.normal.04 #正常交换机queueNormalName: queue.normal.04 #正常队列,没有消费组,设置过期时间exchangeDlxName: exchange.dlx.04 #死信交换机queueDlxName: queue.dlx.04 #死信队列
2.4.1.2、生产者发送消息
package com.power.service;import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageBuilder;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service;import javax.annotation.Resource;
import java.util.Date;@Service
@Slf4j
public class MessageService {@Resourceprivate RabbitTemplate rabbitTemplate;@Beanpublic void sendMsg(){String msg = "hello world";Message message = MessageBuilder.withBody(msg.getBytes()).build();rabbitTemplate.convertAndSend("exchange.normal.04","order",message);log.info("消息发送完毕,发送时间是:"+new Date());}
}
2.4.1.3、生产者配置类
package com.power.config;import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;import java.util.HashMap;
import java.util.Map;@Configuration
public class RabbitConfig {@Value("${my.exchangeNormalName}")private String exchangeNormalName;@Value("${my.queueNormalName}")private String queueNormalName;@Value("${my.exchangeDlxName}")private String exchangeDlxName;@Value("${my.queueDlxName}")private String queueDlxName;/*** 正常交换机* @return*/@Beanpublic DirectExchange normalExchange(){return ExchangeBuilder.directExchange(exchangeNormalName).build();}/*** 正常队列* @return*/@Beanpublic Queue normalQueue(){Map<String, Object> arguments = new HashMap<>();//重点:设置这两个参数//设置队列的死信交换机arguments.put("x-dead-letter-exchange",exchangeDlxName);//设置死信路由key,要跟死信交换机和死信队列绑定的路由key一致arguments.put("x-dead-letter-routing-key","error");return QueueBuilder.durable(queueNormalName).withArguments(arguments) //设置队列的参数.build();}/*** 正常交换机和正常队列绑定* @param normalExchange* @param normalQueue* @return*/@Beanpublic Binding bingNormal(DirectExchange normalExchange,Queue normalQueue){return BindingBuilder.bind(normalQueue).to(normalExchange).with("order");}/*** 死信交换机* @return*/@Beanpublic DirectExchange dlxExchange(){return ExchangeBuilder.directExchange(exchangeDlxName).build();}/*** 死信队列* @return*/@Beanpublic Queue dlxQueue(){return QueueBuilder.durable(queueDlxName).build();}/*** 死信交换机和死信队列绑定* @param dlxExchange* @param dlxQueue* @return*/@Beanpublic Binding bindDlx(DirectExchange dlxExchange,Queue dlxQueue){return BindingBuilder.bind(dlxQueue).to(dlxExchange).with("error");}
}
2.4.2、消费者

2.4.2.1、消费者application.yml 启动手动确认
server:port: 9090
spring:application:name: dlx04-receiverrabbitmq:host: 你的服务器IPport: 5672username: 你的账号password: 你的密码virtual-host: powerlistener:simple:acknowledge-mode: manual
关键配置

2.4.2.2、消费者接收消息
package com.power.service;import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageProperties;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;import java.io.IOException;
import java.util.Date;@Component
@Slf4j
public class MessageReceive {@RabbitListener(queues={"queue.normal.04"})public void receiveMsg(Message message, Channel channel){//获取消息属性MessageProperties messageProperties = message.getMessageProperties();//获取消息的唯一标识,类似学号和身份证号long deliveryTag = messageProperties.getDeliveryTag();try{byte[] body = message.getBody();String msg = new String(body);log.info("监听到的消息是:"+msg+",接收的时间是:"+new Date());//TODO 业务逻辑处理int a=1/0;//消费者的手动确认,false:只确认当前消息,true:批量确认channel.basicAck(deliveryTag,false);}catch (Exception e){log.error("接收者出现问题:{}",e.getMessage());try {//消费者的手动不确认,参数3:是重新入队//不会进入死信队列
// channel.basicNack(deliveryTag,false,true);//消费者的手动不确认,参数3:false 不重新入队(不重新投递),就会变成死信channel.basicNack(deliveryTag,false,false);}catch (IOException ex){throw new RuntimeException(ex);}}}}
关键代码

2.4.3、测试
启动生产者:发送消息

启动消费者:
因业务代码出错,程序处理异常,消息进入死信队列


相关文章:
RabbitMQ的DLX(Dead-Letter-Exchange 死信交换机,死信交换器,死信邮箱)(重要)
RabbitMQ的DLX 1、RabbitMQ死信队列2、代码示例2.1、队列过期2.1.1、配置类RabbitConfig(关键代码)2.1.2、业务类MessageService2.1.3、配置文件application.yml2.1.4、启动类2.1.5、配置文件2.1.6、测试 2.2、消息过期2.2.1、配置类RabbitConfig2.2.2、…...
【STM32F1】——舵机角度控制与TIM定时器
【STM32F1】——舵机角度控制与TIM定时器 一、简介 本篇主要对舵机DS-S002M模块调试过程进行总结,实现了以下功能: 1)舵机转动角度的控制:利用STM32F103C8T6的TIM定时器产生PWM信号控制舵机DS-S002M转动一定的角度。 二、DS-S002M数字舵机介绍 电压:4.8-6.0V操作角度:…...
想要成为独立游戏作者 :通关!游戏设计之道 2-1 HUD
HUD特指显示屏幕上的信息,在是UI的子集,UI是一个游戏中虽有的交互元素的总称 本文用了大量ai总结 + 个人微调,不喜勿喷,前篇如下想要成为独立游戏作者 :通关!游戏设计之道 1-4 操作篇-C…...
sql专题 之 三大范式
文章目录 背景范式介绍第一范式:属性不可再分第二范式第三范式注意事项 为什么不遵循后续的范式数据库范式在实际应用中会遇到哪些挑战? 背景 数据库的范式(Normal Form)是一组规则,用于设计数据库表结构以 减少数据冗…...
node.js安装和配置教程
软件介绍 Node.js是一个免费的、开源的、跨平台的JavaScript运行时环境,允许开发人员在浏览器之外编写命令行工具和服务器端脚本。 Node.js是一个基于Chrome JavaScript运行时建立的一个平台。 Node.js是一个事件驱动I/O服务端JavaScript环境,基于Goo…...
定时器输入捕获实验配置
首先,第一个时基工作参数配置 HAL_TIM_IC_Init( ) 还是一样的套路,传参是一个句柄,先定义一个结构体 Instance:指向TIM_TypeDef的指针,表示定时器的实例。TIM_TypeDef是一个包含了定时器寄存器的结构体,用…...
【C/C++】memcpy函数的使用
零.导言 当我们学习了strcpy和strncpy函数后,也许会疑惑整形数组要如何拷贝,而今天我将讲解的memcpy函数便可以拷贝整形数组。 一.memcpy函数的使用 memcpy函数是一种C语言内存函数,可以按字节拷贝任意类型的数组,比如整形数组。 …...
spring-security(两种权限控制方式)
案例(写死的用户密码) package com.zking.security.service;import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.AuthorityUtils; import org.springframework.security.core.userdetails.User; import org.sp…...
【mongodb】数据库的安装及连接初始化简明手册
NoSQL(NoSQL Not Only SQL ),意即"不仅仅是SQL"。 在现代的计算系统上每天网络上都会产生庞大的数据量。这些数据有很大一部分是由关系数据库管理系统(RDBMS)来处理。 通过应用实践证明,关系模型是非常适合于客户服务器…...
【科普】卷积、卷积核、池化、激活函数、全连接分别是什么?有什么用?
概念定义作用/用途解释举例卷积 (Convolution)是一种数学操作,通过在输入数据(如图片)上滑动卷积核,计算局部区域的加权和。提取数据中的局部特征,例如边缘、角点等。卷积就像在图片上滑动一个小的窗口,计算…...
距离向量路由选择协议和链路状态路由选择协议介绍
距离向量路由选择协议(Distance Vector Routing Protocol)和链路状态路由选择协议(Link-State Routing Protocol)是两种主要的网关协议,它们用于在网络内部选择数据传输的最佳路径。下面分别介绍这两种协议:…...
【AI大模型】大型语言模型LLM基础概览:技术原理、发展历程与未来展望
目录 🍔 大语言模型 (LLM) 背景 🍔 语言模型 (Language Model, LM) 2.1 基于规则和统计的语言模型(N-gram) 2.2 神经网络语言模型 2.3 基于Transformer的预训练语言模型 2.4 大语言模型 🍔 语言模型的评估指标 …...
ubuntu 22.04 server 安装 和 初始化 LTS
ubuntu 22.04 server 安装 和 初始化 下载地址 https://releases.ubuntu.com/jammy/ 使用的镜像是 ubuntu-22.04.5-live-server-amd64.iso usb 启动盘制作工具 https://rufus.ie/zh/ rufus-4.6p.exe 需要主板 支持 UEFI 启动 Ubuntu22.04.4-server安装 流程 https://b…...
大数据机器学习算法与计算机视觉应用03:数据流
Data Stream Streaming ModelExample Streaming QuestionsHeavy HittersAlgorithm 1: For Majority elementMisra Gries AlgorithmApplicationsApproximation of count Streaming Model 数据流模型 数据流就是所有的数据先后到达,而不是同时存储在内存之中。在现…...
【代码随想录day25】【C++复健】491.递增子序列;46.全排列;47.全排列 II;51. N皇后;37. 解数独
491.递增子序列 本题做的时候除了去重逻辑之外,其他的也勉强算是写出来了,不过还是有问题的,总结如下: 1 本题的关键:去重 与其说是不知道用什么去重,更应该说是完全没想到本题需要去重,说明…...
AI智能识物(微信小程序)
AI智能识物,是一款实用的小程序。可以拍照智能识物,可识别地标、车型、花卉、植物、动物、果蔬、货币、红酒、食材等等,AI智能技术识别准确度高。 更新说明: 此源码为1.2.0版本。 主要更新内容:新增security.imgSec…...
游戏引擎学习第三天
视频参考:https://www.bilibili.com/video/BV1XTmqYSEtm/ 之前的程序不能退出,下面写关闭窗体的操作 PostQuitMessage 是 Windows API 中的一个函数,用于向当前线程的消息队列发送一个退出消息。其作用是请求应用程序退出消息循环,通常用于处…...
帝国CMS7.5仿模板堂柒喜模板建站网 素材资源下载站源码
环境要求:phpmysql、支付伪静态 本套模板采用帝国cms7.5版UTF-8开发,一款非常不错的高端建站源码模板, 适用于中小型网络建站工作室源码模板下载站,支持自定义设置会员组。 源码下载:https://download.csdn.net/down…...
聊一聊Spring中的自定义监听器
前言 通过一个简单的自定义的监听器,从源码的角度分一下Spring中监听的整个过程,分析监听的作用。 一、自定义监听案例 1.1定义事件 package com.lazy.snail;import lombok.Getter; import org.springframework.context.ApplicationEvent;/*** Class…...
【王木头】最大似然估计、最大后验估计
目录 一、最大似然估计(MLE) 二、最大后验估计(MAP) 三、MLE 和 MAP 的本质区别 四、当先验是均匀分布时,MLE 和 MAP 等价 五、总结 本文理论参考王木头的视频: 贝叶斯解释“L1和L2正则化”ÿ…...
linux之kylin系统nginx的安装
一、nginx的作用 1.可做高性能的web服务器 直接处理静态资源(HTML/CSS/图片等),响应速度远超传统服务器类似apache支持高并发连接 2.反向代理服务器 隐藏后端服务器IP地址,提高安全性 3.负载均衡服务器 支持多种策略分发流量…...
MongoDB学习和应用(高效的非关系型数据库)
一丶 MongoDB简介 对于社交类软件的功能,我们需要对它的功能特点进行分析: 数据量会随着用户数增大而增大读多写少价值较低非好友看不到其动态信息地理位置的查询… 针对以上特点进行分析各大存储工具: mysql:关系型数据库&am…...
抖音增长新引擎:品融电商,一站式全案代运营领跑者
抖音增长新引擎:品融电商,一站式全案代运营领跑者 在抖音这个日活超7亿的流量汪洋中,品牌如何破浪前行?自建团队成本高、效果难控;碎片化运营又难成合力——这正是许多企业面临的增长困局。品融电商以「抖音全案代运营…...
论文浅尝 | 基于判别指令微调生成式大语言模型的知识图谱补全方法(ISWC2024)
笔记整理:刘治强,浙江大学硕士生,研究方向为知识图谱表示学习,大语言模型 论文链接:http://arxiv.org/abs/2407.16127 发表会议:ISWC 2024 1. 动机 传统的知识图谱补全(KGC)模型通过…...
是否存在路径(FIFOBB算法)
题目描述 一个具有 n 个顶点e条边的无向图,该图顶点的编号依次为0到n-1且不存在顶点与自身相连的边。请使用FIFOBB算法编写程序,确定是否存在从顶点 source到顶点 destination的路径。 输入 第一行两个整数,分别表示n 和 e 的值(1…...
【从零学习JVM|第三篇】类的生命周期(高频面试题)
前言: 在Java编程中,类的生命周期是指类从被加载到内存中开始,到被卸载出内存为止的整个过程。了解类的生命周期对于理解Java程序的运行机制以及性能优化非常重要。本文会深入探寻类的生命周期,让读者对此有深刻印象。 目录 …...
Vite中定义@软链接
在webpack中可以直接通过符号表示src路径,但是vite中默认不可以。 如何实现: vite中提供了resolve.alias:通过别名在指向一个具体的路径 在vite.config.js中 import { join } from pathexport default defineConfig({plugins: [vue()],//…...
Python 训练营打卡 Day 47
注意力热力图可视化 在day 46代码的基础上,对比不同卷积层热力图可视化的结果 import torch import torch.nn as nn import torch.optim as optim from torchvision import datasets, transforms from torch.utils.data import DataLoader import matplotlib.pypl…...
Spring AOP代理对象生成原理
代理对象生成的关键类是【AnnotationAwareAspectJAutoProxyCreator】,这个类继承了【BeanPostProcessor】是一个后置处理器 在bean对象生命周期中初始化时执行【org.springframework.beans.factory.config.BeanPostProcessor#postProcessAfterInitialization】方法时…...
客户案例 | 短视频点播企业海外视频加速与成本优化:MediaPackage+Cloudfront 技术重构实践
01技术背景与业务挑战 某短视频点播企业深耕国内用户市场,但其后台应用系统部署于东南亚印尼 IDC 机房。 随着业务规模扩大,传统架构已较难满足当前企业发展的需求,企业面临着三重挑战: ① 业务:国内用户访问海外服…...
