当前位置: 首页 > news >正文

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&#xff08;关键代码&#xff09;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特指显示屏幕上的信息&#xff0c;在是UI的子集&#xff0c;UI是一个游戏中虽有的交互元素的总称 本文用了大量ai总结 &#xff0b; 个人微调&#xff0c;不喜勿喷&#xff0c;前篇如下想要成为独立游戏作者 &#xff1a;通关&#xff01;游戏设计之道 1-4 操作篇-C…...

sql专题 之 三大范式

文章目录 背景范式介绍第一范式&#xff1a;属性不可再分第二范式第三范式注意事项 为什么不遵循后续的范式数据库范式在实际应用中会遇到哪些挑战&#xff1f; 背景 数据库的范式&#xff08;Normal Form&#xff09;是一组规则&#xff0c;用于设计数据库表结构以 减少数据冗…...

node.js安装和配置教程

软件介绍 Node.js是一个免费的、开源的、跨平台的JavaScript运行时环境&#xff0c;允许开发人员在浏览器之外编写命令行工具和服务器端脚本。 Node.js是一个基于Chrome JavaScript运行时建立的一个平台。 Node.js是一个事件驱动I/O服务端JavaScript环境&#xff0c;基于Goo…...

定时器输入捕获实验配置

首先&#xff0c;第一个时基工作参数配置 HAL_TIM_IC_Init( ) 还是一样的套路&#xff0c;传参是一个句柄&#xff0c;先定义一个结构体 Instance&#xff1a;指向TIM_TypeDef的指针&#xff0c;表示定时器的实例。TIM_TypeDef是一个包含了定时器寄存器的结构体&#xff0c;用…...

【C/C++】memcpy函数的使用

零.导言 当我们学习了strcpy和strncpy函数后&#xff0c;也许会疑惑整形数组要如何拷贝&#xff0c;而今天我将讲解的memcpy函数便可以拷贝整形数组。 一.memcpy函数的使用 memcpy函数是一种C语言内存函数&#xff0c;可以按字节拷贝任意类型的数组&#xff0c;比如整形数组。 …...

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 )&#xff0c;意即"不仅仅是SQL"。 在现代的计算系统上每天网络上都会产生庞大的数据量。这些数据有很大一部分是由关系数据库管理系统&#xff08;RDBMS&#xff09;来处理。 通过应用实践证明&#xff0c;关系模型是非常适合于客户服务器…...

【科普】卷积、卷积核、池化、激活函数、全连接分别是什么?有什么用?

概念定义作用/用途解释举例卷积 (Convolution)是一种数学操作&#xff0c;通过在输入数据&#xff08;如图片&#xff09;上滑动卷积核&#xff0c;计算局部区域的加权和。提取数据中的局部特征&#xff0c;例如边缘、角点等。卷积就像在图片上滑动一个小的窗口&#xff0c;计算…...

距离向量路由选择协议和链路状态路由选择协议介绍

距离向量路由选择协议&#xff08;Distance Vector Routing Protocol&#xff09;和链路状态路由选择协议&#xff08;Link-State Routing Protocol&#xff09;是两种主要的网关协议&#xff0c;它们用于在网络内部选择数据传输的最佳路径。下面分别介绍这两种协议&#xff1a…...

【AI大模型】大型语言模型LLM基础概览:技术原理、发展历程与未来展望

目录 &#x1f354; 大语言模型 (LLM) 背景 &#x1f354; 语言模型 (Language Model, LM) 2.1 基于规则和统计的语言模型&#xff08;N-gram&#xff09; 2.2 神经网络语言模型 2.3 基于Transformer的预训练语言模型 2.4 大语言模型 &#x1f354; 语言模型的评估指标 …...

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 数据流模型 数据流就是所有的数据先后到达&#xff0c;而不是同时存储在内存之中。在现…...

【代码随想录day25】【C++复健】491.递增子序列;46.全排列;47.全排列 II;51. N皇后;37. 解数独

491.递增子序列 本题做的时候除了去重逻辑之外&#xff0c;其他的也勉强算是写出来了&#xff0c;不过还是有问题的&#xff0c;总结如下&#xff1a; 1 本题的关键&#xff1a;去重 与其说是不知道用什么去重&#xff0c;更应该说是完全没想到本题需要去重&#xff0c;说明…...

AI智能识物(微信小程序)

AI智能识物&#xff0c;是一款实用的小程序。可以拍照智能识物&#xff0c;可识别地标、车型、花卉、植物、动物、果蔬、货币、红酒、食材等等&#xff0c;AI智能技术识别准确度高。 更新说明&#xff1a; 此源码为1.2.0版本。 主要更新内容&#xff1a;新增security.imgSec…...

游戏引擎学习第三天

视频参考:https://www.bilibili.com/video/BV1XTmqYSEtm/ 之前的程序不能退出&#xff0c;下面写关闭窗体的操作 PostQuitMessage 是 Windows API 中的一个函数&#xff0c;用于向当前线程的消息队列发送一个退出消息。其作用是请求应用程序退出消息循环&#xff0c;通常用于处…...

帝国CMS7.5仿模板堂柒喜模板建站网 素材资源下载站源码

环境要求&#xff1a;phpmysql、支付伪静态 本套模板采用帝国cms7.5版UTF-8开发&#xff0c;一款非常不错的高端建站源码模板&#xff0c; 适用于中小型网络建站工作室源码模板下载站&#xff0c;支持自定义设置会员组。 源码下载&#xff1a;https://download.csdn.net/down…...

聊一聊Spring中的自定义监听器

前言 通过一个简单的自定义的监听器&#xff0c;从源码的角度分一下Spring中监听的整个过程&#xff0c;分析监听的作用。 一、自定义监听案例 1.1定义事件 package com.lazy.snail;import lombok.Getter; import org.springframework.context.ApplicationEvent;/*** Class…...

【王木头】最大似然估计、最大后验估计

目录 一、最大似然估计&#xff08;MLE&#xff09; 二、最大后验估计&#xff08;MAP&#xff09; 三、MLE 和 MAP 的本质区别 四、当先验是均匀分布时&#xff0c;MLE 和 MAP 等价 五、总结 本文理论参考王木头的视频&#xff1a; 贝叶斯解释“L1和L2正则化”&#xff…...

[特殊字符] 智能合约中的数据是如何在区块链中保持一致的?

&#x1f9e0; 智能合约中的数据是如何在区块链中保持一致的&#xff1f; 为什么所有区块链节点都能得出相同结果&#xff1f;合约调用这么复杂&#xff0c;状态真能保持一致吗&#xff1f;本篇带你从底层视角理解“状态一致性”的真相。 一、智能合约的数据存储在哪里&#xf…...

深入剖析AI大模型:大模型时代的 Prompt 工程全解析

今天聊的内容&#xff0c;我认为是AI开发里面非常重要的内容。它在AI开发里无处不在&#xff0c;当你对 AI 助手说 "用李白的风格写一首关于人工智能的诗"&#xff0c;或者让翻译模型 "将这段合同翻译成商务日语" 时&#xff0c;输入的这句话就是 Prompt。…...

2024年赣州旅游投资集团社会招聘笔试真

2024年赣州旅游投资集团社会招聘笔试真 题 ( 满 分 1 0 0 分 时 间 1 2 0 分 钟 ) 一、单选题(每题只有一个正确答案,答错、不答或多答均不得分) 1.纪要的特点不包括()。 A.概括重点 B.指导传达 C. 客观纪实 D.有言必录 【答案】: D 2.1864年,()预言了电磁波的存在,并指出…...

Frozen-Flask :将 Flask 应用“冻结”为静态文件

Frozen-Flask 是一个用于将 Flask 应用“冻结”为静态文件的 Python 扩展。它的核心用途是&#xff1a;将一个 Flask Web 应用生成成纯静态 HTML 文件&#xff0c;从而可以部署到静态网站托管服务上&#xff0c;如 GitHub Pages、Netlify 或任何支持静态文件的网站服务器。 &am…...

从零实现STL哈希容器:unordered_map/unordered_set封装详解

本篇文章是对C学习的STL哈希容器自主实现部分的学习分享 希望也能为你带来些帮助~ 那咱们废话不多说&#xff0c;直接开始吧&#xff01; 一、源码结构分析 1. SGISTL30实现剖析 // hash_set核心结构 template <class Value, class HashFcn, ...> class hash_set {ty…...

Fabric V2.5 通用溯源系统——增加图片上传与下载功能

fabric-trace项目在发布一年后,部署量已突破1000次,为支持更多场景,现新增支持图片信息上链,本文对图片上传、下载功能代码进行梳理,包含智能合约、后端、前端部分。 一、智能合约修改 为了增加图片信息上链溯源,需要对底层数据结构进行修改,在此对智能合约中的农产品数…...

论文阅读笔记——Muffin: Testing Deep Learning Libraries via Neural Architecture Fuzzing

Muffin 论文 现有方法 CRADLE 和 LEMON&#xff0c;依赖模型推理阶段输出进行差分测试&#xff0c;但在训练阶段是不可行的&#xff0c;因为训练阶段直到最后才有固定输出&#xff0c;中间过程是不断变化的。API 库覆盖低&#xff0c;因为各个 API 都是在各种具体场景下使用。…...

Elastic 获得 AWS 教育 ISV 合作伙伴资质,进一步增强教育解决方案产品组合

作者&#xff1a;来自 Elastic Udayasimha Theepireddy (Uday), Brian Bergholm, Marianna Jonsdottir 通过搜索 AI 和云创新推动教育领域的数字化转型。 我们非常高兴地宣布&#xff0c;Elastic 已获得 AWS 教育 ISV 合作伙伴资质。这一重要认证表明&#xff0c;Elastic 作为 …...

人工智能 - 在Dify、Coze、n8n、FastGPT和RAGFlow之间做出技术选型

在Dify、Coze、n8n、FastGPT和RAGFlow之间做出技术选型。这些平台各有侧重&#xff0c;适用场景差异显著。下面我将从核心功能定位、典型应用场景、真实体验痛点、选型决策关键点进行拆解&#xff0c;并提供具体场景下的推荐方案。 一、核心功能定位速览 平台核心定位技术栈亮…...

聚六亚甲基单胍盐酸盐市场深度解析:现状、挑战与机遇

根据 QYResearch 发布的市场报告显示&#xff0c;全球市场规模预计在 2031 年达到 9848 万美元&#xff0c;2025 - 2031 年期间年复合增长率&#xff08;CAGR&#xff09;为 3.7%。在竞争格局上&#xff0c;市场集中度较高&#xff0c;2024 年全球前十强厂商占据约 74.0% 的市场…...