Rabbitmq与交换机

news2024/9/19 10:39:37

目录

一、交换机简介

1、Exchange(交换机)的作用

 2、Exchange(交换机)的类型

3、交换机的属性

 二、交换机的使用

1、创建项目

 2、给子模块添加依赖( rabbitmq-provider、 rabbitmq-consumer)

3、直连交换机(Direct Exchange)使用

 4、主题交换机(Topic Exchange)的使用

5、扇形交换机(Fanout Exchange)


一、交换机简介

1、Exchange(交换机)的作用

 在RabbitMQ中,生产者发送消息不会直接将消息投递到队列中,而是先将消息投递到交换机中,在由交换机转发到具体的队列,
   队列再将消息以推送或者拉取方式给消费者进行消费

          创建消息              路由键         pull/push
   生产者------------>交换机------------>队列------------>消费者

 

 2、Exchange(交换机)的类型

①直连交换机:Direct Exchange

直连交换机是一种带路由功能的交换机,一个队列会和一个交换机绑定,除此之外再绑定一个routing_key,当消息被发送的时候,需要指定一个binding_key,这个消息被送达交换机的时候,就会被这个交换机送到指定的队列里面去。同样的一个binding_key也是支持应用到多个队列中的。

     这样当一个交换机绑定多个队列,就会被送到对应的队列去处理。

     注1:什么是路由键 
          每个消息都有一个称为路由键(routing key)的属性,它其实就是一个简单的字符串

     注2:直连交换机适用场景
          有优先级的任务,根据任务的优先级把消息发送到对应的队列,这样可以指派更多的资源去处理高优先级的队列。

 ②主题交换机:Topic Exchange

直连交换机的缺点!
     直连交换机的routing_key方案非常简单,如果我们希望一条消息发送给多个队列,那么这个交换机需要绑定上非常多的routing_key,
     假设每个交换机上都绑定一堆的routing_key连接到各个队列上。那么消息的管理就会异常地困难。
     
     所以RabbitMQ提供了一种主题交换机,发送到主题交换机上的消息需要携带指定规则的routing_key,
     主题交换机会根据这个规则将数据发送到对应的(多个)队列上。

     主题交换机的routing_key需要有一定的规则,交换机和队列的binding_key需要采用*.#.*.....的格式,每个部分用.分开,其中
     *表示一个单词 
     #表示任意数量(零个或多个)单词。

     示例:
     队列Q1绑定键为 *.TT.*
     队列Q2绑定键为TT.#

     如果一条消息携带的路由键为 A.TT.B,那么队列Q1将会收到 
     如果一条消息携带的路由键为TT.AA.BB,那么队列Q2将会收到

 ③扇形交换机:Fanout Exchange

扇形交换机是最基本的交换机类型,它所能做的事情非常简单———广播消息。
     扇形交换机会把能接收到的消息全部发送给绑定在自己身上的队列。因为广播不需要“思考”,
     所以扇形交换机处理消息的速度也是所有的交换机类型里面最快的。 

     这个交换机没有路由键概念,就算你绑了路由键也是无视的。 

 ④首部交换机:Headers exchange

⑤默认交换机

实际上是一个由RabbitMQ预先声明好的名字为空字符串的直连交换机(direct exchange)。它有一个特殊的属性使得它对于
     简单应用特别有用处:那就是每个新建队列(queue)都会自动绑定到默认交换机上,绑定的路由键(routing key)名称与队列名称相同。

     如:当你声明了一个名为”hello”的队列,RabbitMQ会自动将其绑定到默认交换机上,绑定(binding)的路由键名称也是为”hello”。
     因此,当携带着名为”hello”的路由键的消息被发送到默认交换机的时候,此消息会被默认交换机路由至名为”hello”的队列中
  
     类似amq.*的名称的交换机:
     这些是RabbitMQ默认创建的交换机。这些队列名称被预留做RabbitMQ内部使用,不能被应用使用,否则抛出403 (ACCESS_REFUSED)错误

 ⑥Dead Letter Exchange(死信交换机)

在默认情况,如果消息在投递到交换机时,交换机发现此消息没有匹配的队列,则这个消息将被悄悄丢弃。
     为了解决这个问题,RabbitMQ中有一种交换机叫死信交换机。当消费者不能处理接收到的消息时,将这个消息重新发布到另外一个队列中,
     等待重试或者人工干预。这个过程中的exchange和queue就是所谓的”Dead Letter Exchange 和 Queue

3、交换机的属性

除交换机类型外,在声明交换机时还可以附带许多其他的属性,其中最重要的几个分别是:
   Name:交换机名称
   Durability:是否持久化。如果持久性,则RabbitMQ重启后,交换机还存在
   Auto-delete:当所有与之绑定的消息队列都完成了对此交换机的使用后,删掉它
   Arguments:扩展参数

 二、交换机的使用

1、创建项目

     rabbitmq02                        主模块
     rabbitmq-provider              生产者(子模块)
     rabbitmq-consumer           消费者(子模块)

 2、给子模块添加依赖( rabbitmq-provider、 rabbitmq-consumer)

<dependency>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter-amqp</artifactId>
     </dependency>
     <dependency>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter-web</artifactId>
     </dependency>
     <dependency>
       <groupId>org.projectlombok</groupId>
       <artifactId>lombok</artifactId>
       <optional>true</optional>
     </dependency>

3、直连交换机(Direct Exchange)使用

yml:

server:
    port: 8080
spring:
    rabbitmq:
        host: 192.168.118.129
        password: admin
        port: 5672
        username: admin
        virtual-host: my_vhost

RabbitmqDirectConfig

package com.yzq.rabbitmqconsumer.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 白未
 * @site 3185579318
 * @company xxx公司
 * @create  2022-12-18 21:29
 */
@Configuration
public class RabbitmqDirectConfig {
    //直连交换机对应的队列
    @Bean
    public Queue directQueue(){

        return new Queue("yzq-direct-Queue");
    }

    //直连交换机
    @Bean
    public DirectExchange directExchange(){

        return new DirectExchange("yzq-direct-exchange");
    }

    //直连交换机与队列的绑定关系
    @Bean
    public Binding directBinding(){
        return BindingBuilder.bind(directQueue())
                .to(directExchange())
                .with("direct_routing_key");
    }
}

SendMessageController

package com.yzq.rabbitmqconsumer.controller;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Map;

/**
 * @author 白未
 * @site 3185579318
 * @company xxx公司
 * @create  2022-12-18 21:40
 */
@RestController
public class SendMessageController {
    @Autowired
    public RabbitTemplate rabbitTemplate;

    @RequestMapping("/s")
    public Map sendDirect(String routingKey){
        Map msg = new HashMap();
        msg.put("msg","直连交换机 yzq-direct-exchange 发送的消息");
        msg.put("time", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss")));
        rabbitTemplate.convertAndSend("yzq-direct-exchange"
        ,routingKey,msg);

        Map res = new HashMap();
        res.put("code",200);
        res.put("msg","成功");
        return res;
    }
}

运行:

 创建消息接收监听类DirectReceiver

package com.yzq.rabbitmqconsumer.config;

import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
		@RabbitListener(queues = {"yzq-direct-Queue"})
		public class DirectReceiver {
			// @RabbitListener(queues = {"direct-queue"})
			@RabbitHandler
			public void handler(Map msg){

				System.out.println(msg);
			}
		}

注1:新版jdk日期及格式化
          LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));

     注2:rabbitTemplate和amqpTemplate有什么关系
          查看源码中会发现rabbitTemplate实现自amqpTemplate接口,两者使用起来并无区别,功能一致

     注3:不要@Configuration写成了@Configurable,这两个长得很像
          @Configuration该注解是可以用来替代XML文件。
          手动new出来的对象,正常情况下,Spring是无法依赖注入的,这个时候可以使用@Configurable注解

 4、主题交换机(Topic Exchange)的使用

 RabbitTopicConfig

package com.yzq.rabbitmqprovider.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 白未
 * @site 3185579318
 * @company xxx公司
 * @create  2022-12-19 1:02
 */
@Configuration
public class RabbitTopicConfig {


        //队列
        @Bean
        public Queue topicQueueA(){
            return new Queue("yzq-topic-Queue-a");
        }
        @Bean
        public Queue topicQueueB(){
            return new Queue("yzq-topic-Queue-b");
        }
        @Bean
        public Queue topicQueueC(){
            return new Queue("yzq-topic-Queue-c");
        }

        //交换机
        @Bean
        public TopicExchange topicExchange(){
            return new TopicExchange("yzq-topic-Exchange");
        }


        //绑定关系
        @Bean
        public Binding binding1(){
            return BindingBuilder.bind(topicQueueA())
                    .to(topicExchange())
                    .with("yzq.person.xx");
        }

        @Bean
        public Binding binding2(){
            return BindingBuilder.bind(topicQueueB())
                    .to(topicExchange())
                    .with("yzq.person.yy");
        }

        @Bean
        public Binding binding3(){
            return BindingBuilder.bind(topicQueueC())
                    .to(topicExchange())
                    .with("yzq.person.*");
        }

}

SendMessageControlle

package com.yzq.rabbitmqprovider.controller;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Map;

/**
 * @author 白未
 * @site 3185579318
 * @company xxx公司
 * @create  2022-12-18 21:40
 */
@RestController
public class SendMessageController {
    @Autowired
    public RabbitTemplate rabbitTemplate;

    //直连交换机推送消息
    @RequestMapping("/s")
    public Map sendDirect(String routingKey){
        Map msg = new HashMap();
        msg.put("msg","直连交换机 yzq-direct-exchange 发送的消息");
        msg.put("time", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss")));
        rabbitTemplate.convertAndSend("yzq-direct-exchange"
        ,routingKey,msg);

        Map res = new HashMap();
        res.put("code",200);
        res.put("msg","成功");
        return res;
    }

    //主题交换机推送方式
    @RequestMapping("/sT")
    public Map sendTopic(String routingKey){
        Map msg = new HashMap();
        msg.put("msg","直连交换机 yzq-Topic-exchange 发送的消息");
        msg.put("time", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss")));
        rabbitTemplate.convertAndSend("yzq-Topic-exchange"
                ,routingKey,msg);

        Map res = new HashMap();
        res.put("code",200);
        res.put("msg","成功");
        return res;
    }
}

运行:

TopicReceiver
package com.yzq.rabbitmqconsumer.config;

import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class TopicReceiver {
	@RabbitListener(queues = {"yzq-topic-Queue-a"})
	@RabbitHandler
	public void handler1(Map msg){

		System.out.println("消费者订阅:yzq-topic-Queue-a队列的消息为:"+msg);
	}

	@RabbitListener(queues = {"yzq-topic-Queue-b"})
	@RabbitHandler
	public void handler2(Map msg){

		System.out.println("消费者订阅:yzq-topic-Queue-b队列的消息为:"+msg);
	}

	@RabbitListener(queues = {"yzq-topic-Queue-c"})
	@RabbitHandler
	public void handler3(Map msg){

		System.out.println("消费者订阅:yzq-topic-Queue-c队列的消息为:"+msg);
	}
}

运行:

5、扇形交换机(Fanout Exchange)

RabbitmqFanoutConfig

package com.yzq.rabbitmqprovider.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 白未
 * @site 3185579318
 * @company xxx公司
 * @create  2022-12-19 1:02
 */
@Configuration
public class RabbitFanoutConfig {


    //队列
    @Bean
    public Queue fanoutQueueA(){
        return new Queue("yzq-topic-Queue-a");
    }
    @Bean
    public Queue fanoutQueueB(){
        return new Queue("yzq-topic-Queue-b");
    }
    @Bean
    public Queue fanoutQueueC(){
        return new Queue("yzq-topic-Queue-c");
    }

    //交换机
    @Bean
    public FanoutExchange fanoutExchange(){
        return new FanoutExchange("yzq-fanout-Exchange");
    }


    //绑定关系
    @Bean
    public Binding bindingFanout1(){
        return BindingBuilder.bind(fanoutQueueA())
                .to(fanoutExchange());
    }

    @Bean
    public Binding bindingFanout2(){
        return BindingBuilder.bind(fanoutQueueB())
                .to(fanoutExchange());
    }

    @Bean
    public Binding bindingFanout3(){
        return BindingBuilder.bind(fanoutQueueC())
                .to(fanoutExchange());
    }


}

     //因为是扇型交换机, 路由键无需配置,配置也不起作用,两处地方均未配置路由键
     BindingBuilder.bind(queueA()).to(fanoutExchange()); 
     rabbitTemplate.convertAndSend(RabbitFanoutConfig.EXCHANGE_NAME,null, map);

SendMessageControlle

package com.yzq.rabbitmqprovider.controller;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Map;

/**
 * @author 白未
 * @site 3185579318
 * @company xxx公司
 * @create  2022-12-18 21:40
 */
@RestController
public class SendMessageController {
    @Autowired
    public RabbitTemplate rabbitTemplate;

    //直连交换机推送消息
    @RequestMapping("/s")
    public Map sendDirect(String routingKey){
        Map msg = new HashMap();
        msg.put("msg","直连交换机 yzq-direct-exchange 发送的消息");
        msg.put("time", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss")));
        rabbitTemplate.convertAndSend("yzq-direct-exchange"
        ,routingKey,msg);

        Map res = new HashMap();
        res.put("code",200);
        res.put("msg","成功");
        return res;
    }

    //主题交换机推送方式
    @RequestMapping("/sT")
    public Map sendTopic(String routingKey){
        Map msg = new HashMap();
        msg.put("msg","主题交换机 yzq-topic-Exchange 发送的消息");
        msg.put("time", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss")));
        rabbitTemplate.convertAndSend("yzq-topic-Exchange"
                ,routingKey,msg);

        Map res = new HashMap();
        res.put("code",200);
        res.put("msg","成功");
        return res;
    }

    //扇形交换机推送方式
    @RequestMapping("/sF")
    public Map sendFanout(){
        Map msg = new HashMap();
        msg.put("msg","扇形交换机 yzq-topic-Exchange 发送的消息");
        msg.put("time", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss")));
        rabbitTemplate.convertAndSend("yzq-fanout-Exchange"
                ,null,msg);

        Map res = new HashMap();
        res.put("code",200);
        res.put("msg","成功");
        return res;
    }
}

 运行:

FanoutReceiver
package com.yzq.rabbitmqconsumer.config;

import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class FanoutReceiver {
	@RabbitListener(queues = {"yzq-fanout-Queue-a"})
	@RabbitHandler
	public void handler1(Map msg){

		System.out.println("消费者订阅:yzq-fanout-Queue-a队列的消息为:"+msg);
	}

	@RabbitListener(queues = {"yzq-fanout-Queue-b"})
	@RabbitHandler
	public void handler2(Map msg){

		System.out.println("消费者订阅:yzq-fanout-Queue-b队列的消息为:"+msg);
	}

	@RabbitListener(queues = {"yzq-fanout-Queue-c"})
	@RabbitHandler
	public void handler3(Map msg){

		System.out.println("消费者订阅:yzq-fanout-Queue-c队列的消息为:"+msg);
	}
}

运行:

 

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

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

相关文章

【图像分割】和声搜索算法图像多级阈值分割【含Matlab源码 2044期】

⛄一、和声搜索算法的图像阈值寻优算法简介 苹果图像识别是指将苹果果实从枝叶、土壤、天空等背景中分离出来, 即图像分割。最大类间方差法 (OTSU算法)是由日本学者大津展之 (OTSU) 提出的全局阈值选取方法。该方法存在缺乏自适应性、易造成噪声干扰和过分割现象、运算需要大量…

[附源码]计算机毕业设计Python的项目管理系统(程序+源码+LW文档)

该项目含有源码、文档、程序、数据库、配套开发软件、软件安装教程 项目运行 环境配置&#xff1a; Pychram社区版 python3.7.7 Mysql5.7 HBuilderXlist pipNavicat11Djangonodejs。 项目技术&#xff1a; django python Vue 等等组成&#xff0c;B/S模式 pychram管理等…

Kafka 安装 快速入门

Kafka 安装 快速入门 Apache Kafka是流行的用于大规模收集、处理、存储和分析数据的开源流处理系统。它以其卓越的性能、低延迟、容错和高吞吐量而闻名&#xff0c;能够每秒处理数千条消息。常用来构建数据管道、利用实时数据流、实现系统监控、数据集成。 如上图&#xff0c;…

【MindStudio训练营第一季】基于MindX的U-Net网络的工业质检实践作业

1.1 作业介绍 1.1.1 作业背景 随着新一轮科技革命和产业变革的加速演进&#xff0c;全球各国都在借助新技术推动制造业升级&#xff0c;从工业2.0自动化开始兴起&#xff0c;到工业3.0信息化普及&#xff0c;如今正迈向工业4.0智能化。借助IoT、工业大数据、人工智能等先进技…

“==” 操作符 与 equals 方法的区别,toString

“” 操作符 与 equals 方法的区别&#xff0c;toString 每博一文案 读过这样一段话&#xff1a;很多人都羡慕我的坚强独立&#xff0c;夸赞我的善解人意。无论什么事情&#xff0c; 我都会把别人放在首位&#xff0c;宁愿自己吃亏&#xff0c;也会尽力满足别人的需求&#xf…

Allegro关闭线段显示不连续效果操作指导

Allegro关闭线段显示不连续效果操作指导 用Allegro进行PCB设计的时候偶尔会出现线段不连续的情况,尤其是在线段拐弯处,实际上并不是线段没有连接上,只是一个显示效果而已,如下图 如何去关闭这个显示效果,具体操作如下 选择Setup-Design Parameter 选择Display 取消勾…

java中实现分页的常见几种方式

文章目录1. 前言2. 先说结论3. 例子1. 数据库SQL的限制条件(limit、fetch&#xff09;2. 使用List集合的截取功能实现3. 插件PageHelper1. 前言 无论是自我学习中&#xff0c;还是在工作中&#xff0c;固然会遇到与前端搭配实现分页的功能&#xff0c;发现有几种方式&#xff…

IIC总线(二)-----IIC控制器与MPU6050

1.Exynos_4412下的IIC控制器 Exynos 4412 SCP简化指令集计算机&#xff08;RISC&#xff09;微处理器支持四个多主控间集成电路&#xff08;I2C&#xff09;总线串行接口。为了在连接到I2C总线的总线主机和外围设备之间传输信息&#xff0c;我们使用了一条专用的串行数据线&am…

IO流(一)

IO流的思维导图如下所示&#xff1a; 我们下来对文件、IO流原理及流的分类&#xff0c;节点流&#xff08;访问文件的、访问数组的、访问管道的&#xff09;和处理流&#xff08;缓冲流、对象流、管道流&#xff09;&#xff0c;输入流&#xff08;InputStream和Reader)和输出流…

[附源码]Nodejs计算机毕业设计基于协同过滤技术的旅游景点购票系统Express(程序+LW)

该项目含有源码、文档、程序、数据库、配套开发软件、软件安装教程。欢迎交流 项目运行 环境配置&#xff1a; Node.js Vscode Mysql5.7 HBuilderXNavicat11VueExpress。 项目技术&#xff1a; Express框架 Node.js Vue 等等组成&#xff0c;B/S模式 Vscode管理前后端分…

Python+Selenium自动化测试详细教程

前言 PythonSelenium 来实现的web端自动化, 以下演示会用到禅道、百度和自己编写的html. 一、准备工作 1、安装 安装Python 3安装selenium库&#xff0c;命令&#xff1a;pip install selenium搭建禅道环境 2、导入浏览器驱动 selenium操作不同的浏览器&#xff0c;需要下…

Windows10 系统下载网址推荐(二)

Windows10 系统下载网址推荐&#xff08;二&#xff09;1. 计算机操作系统概述2.HelloWindows3. 山己几子木4. xitongku5. TechBench结束语1. 计算机操作系统概述 操作系统&#xff08;Operating System&#xff0c;OS&#xff09;是一组主管并控制计算机操作、运用和运行硬件…

设计一个接口务必考虑好这14个基本点

目录&#xff1a;导读 前言 1、入参合法性校验 2、接口的版本控制 3、接口考虑幂等性 4、接口考虑防止重复请求 5、提高接口的响应时间 6、接口限流控制 7、黑白IP白名单 8、敏感数据脱敏 9、请求接口的先决条件-token 10、记录接口请求日志 11、调用第三方接口要考…

分解优化react对redux的基础使用

之前写了 react18 通过redux 做一个简单的状态管理基站 但代码确实相对比较乱 这次进行一些小封装和分解 优化一下管理质量 首先 我们创建一个 react项目 然后在项目中引入 npm install redux --save在src目录下创建 reducers 文件夹 下面创建 counter.js counter.js 参考代码…

有什么免费python安装包?

前言 Python的安装涉及到&#xff1a;Python编辑器、Python解释器、Python包管理工具&#xff08;pip&#xff09;。因此&#xff0c;首先我们要搞清楚这三个东西都是啥。 Python编辑器 正如在电脑上编辑文档需要用Word、处理数据需要用Excel、做演示文稿需要用PPT、修图需要…

git add 命令详解

1. 前言 2. git add 基本操作 3. git add 命令参数 4. git add 背后做了什么 1. 前言 众所周知&#xff0c;git 中有工作区、暂存区、版本库三大组成部分 工作区: 电脑中能看到的目录&#xff0c;也就是写代码的地方 暂存区: 英文叫 stage 或 index。一般存放在 .git 目录下…

【图像分割】灰狼算法最小交叉熵多阈值图像分割【含Matlab源码 903期】

⛄一、最小交叉熵多阈值图像分割简介 1 单阈值分割 设有两个概率分布P{p1, p2, …, pN}和Q{q1, q2, …, qN}, 交叉熵度量它们之间的信息量差异。其对称形式为 交叉熵既可看成是采用P取代Q作为单个系统概率分布时系统信息量变化的期望值, 也可看成是两个概率系统P和Q之间的信息…

CSAPP-Lab5 CacheLab解析

Review Cache Struct A cache is a set of 2s2^s2s cache setsA cache set is a set of E cache lines if E1, it is called “direct-mapped” Each cache line stores a blockTotal Capacity S * B * E 由此&#xff0c;我们可以写出cache line和cache的结构&#xff1a; …

微服务框架 SpringCloud微服务架构 服务异步通讯 50 消息可靠性 50.4 失败重试机制 50.4.1 消费者失败重试

微服务框架 【SpringCloudRabbitMQDockerRedis搜索分布式&#xff0c;系统详解springcloud微服务技术栈课程|黑马程序员Java微服务】 服务异步通讯 文章目录微服务框架服务异步通讯50 消息可靠性50.4 失败重试机制50.4.1 消费者失败重试50 消息可靠性 50.4 失败重试机制 50…

可路由计算引擎实现前置数据库

❤️作者主页&#xff1a;小虚竹 ❤️作者简介&#xff1a;大家好,我是小虚竹。Java领域优质创作者&#x1f3c6;&#xff0c;CSDN博客专家&#x1f3c6;&#xff0c;华为云享专家&#x1f3c6;&#xff0c;掘金年度人气作者&#x1f3c6;&#xff0c;阿里云专家博主&#x1f3…