java中使用rabbitmq

news2024/9/30 17:28:00

文章目录

  • 前言
  • 一、引入和配置
    • 1.引入
    • 2.配置
  • 二、使用
    • 1.队列
    • 2.发布/订阅
      • 2.1 fanout(广播)
      • 2.2 direct(Routing/路由)
      • 2.3 Topics(主题)
      • 2.4 Headers
  • 总结


前言

mq常用于业务解耦、流量削峰和异步通信,rabbitmq是使用范围较广,比较稳定的一款开源产品,接下来我们使用springboot的starter来引入rabbitmq,了解mq的几种使用模式,通过几个简单的案例,让你可以快速地了解到该使用哪种模式来对应业务场景,使用rabbitmq看这一篇就够了,下方附安装链接。


一、引入和配置

1.引入

Spring AMQP高级消息队列协议有两部分组成,spring-amqp是基础抽象,spring-rabbit是RabbitMQ实现。

<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>

在这里插入图片描述

2.配置

配置参考RabbitProperties.java

spring:
  rabbitmq:
    host: 192.168.137.192
    port: 5672
    username: guest
    password: guest
    virtualHost: /

二、使用

1.队列

在这里插入图片描述
RabbitConfiguration

package com.student.rabbit.queue;

import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Bean;
import org.springframework.amqp.core.Queue;
/**
 * Create by zjg on 2024/3/9
 */
@Configuration
public class RabbitConfiguration {
    protected final String queueName = "queue";
    @Bean
    public Queue queue() {
        return new Queue(this.queueName);
    }
}

Producer

package rabbit.queue;

import com.student.SpringbootStart;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.amqp.core.Queue;
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.concurrent.atomic.AtomicInteger;

/**
 * Create by zjg on 2024/3/9
 */
@RunWith(SpringRunner.class)
@SpringBootTest(classes = SpringbootStart.class)
public class Producer {
    @Autowired
    private RabbitTemplate template;
    @Autowired
    private Queue queue;

    AtomicInteger count = new AtomicInteger(0);
    @Test
    public void send() {
        for (int i = 0; i < 10; i++) {
            StringBuilder builder = new StringBuilder("Hello");
            builder.append(" "+count.incrementAndGet());
            String message = builder.toString();
            template.convertAndSend(queue.getName(), message);
            System.out.println(" [x] Sent '" + message + "'");
        }
    }
}

Consumer

package com.student.rabbit.queue;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * Create by zjg on 2024/3/9
 */
@Component
public class Consumer {
    private static final Logger log = LoggerFactory.getLogger(Consumer.class);
    protected final String queueName = "queue";
    @RabbitListener(queues = queueName)
    public void receive1(String message){
        log.debug("receive1:"+message);
    }
    @RabbitListener(queues = queueName)
    public void receive2(String message){
        log.debug("receive2:"+message);
    }
}

每个队列都消费了5条消息
在这里插入图片描述

2.发布/订阅

交换机类型有fanout,direct, topic, headers四种,接下来我们来学习每种方式的使用以及它们的区别。

2.1 fanout(广播)

P(生产者)产生消息给到X(交换机),X分发给绑定的所有队列。

在这里插入图片描述

RabbitFanoutConfiguration
我们定义了AnonymousQueue,它创建了一个具有生成名称的非持久、独占、自动删除队列

package com.student.rabbit.fanout;

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

/**
 * Create by zjg on 2024/3/10
 */
@Configuration
public class RabbitFanoutConfiguration {
    @Bean
    public FanoutExchange fanout() {
        return new FanoutExchange("sys.fanout");
    }
    private static class ReceiverConfig {
        @Bean
        public Queue fanoutQueue1() {
            return new AnonymousQueue();
        }
        @Bean
        public Queue fanoutQueue2() {
            return new AnonymousQueue();
        }
        @Bean
        public Binding bindingFanout1(FanoutExchange fanout,Queue fanoutQueue1) {
            return BindingBuilder.bind(fanoutQueue1).to(fanout);
        }
        @Bean
        public Binding bindingFanout2(FanoutExchange fanout,Queue fanoutQueue2) {
            return BindingBuilder.bind(fanoutQueue2).to(fanout);
        }
    }
}


FanoutProducer

package rabbit.fanout;

import com.student.SpringbootStart;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.amqp.core.FanoutExchange;
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.concurrent.atomic.AtomicInteger;

/**
 * Create by zjg on 2024/3/10
 */
@RunWith(SpringRunner.class)
@SpringBootTest(classes = SpringbootStart.class)
public class FanoutProducer {
    @Autowired
    private RabbitTemplate template;
    @Autowired
    private FanoutExchange fanout;
    @Test
    public void send() {
        AtomicInteger count = new AtomicInteger(0);
        for (int i = 0; i < 10; i++) {
            StringBuilder builder = new StringBuilder("Hello");
            builder.append(" "+count.incrementAndGet());
            String message = builder.toString();
            template.convertAndSend(fanout.getName(), "", message);
            System.out.println(" [x] Sent '" + message + "'");
        }
    }
}

FanoutConsumer

package com.student.rabbit.fanout;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * Create by zjg on 2024/3/10
 */
@Component
public class FanoutConsumer {
    private static final Logger log = LoggerFactory.getLogger(FanoutConsumer.class);
    @RabbitListener(queues = "#{fanoutQueue1.name}")
    public void receive1(String message){
        log.debug("receive1:"+message);
    }
    @RabbitListener(queues = "#{fanoutQueue2.name}")
    public void receive2(String message){
        log.debug("receive2:"+message);
    }
}

总共发送10条消息,每个队列都消费了10条
在这里插入图片描述

2.2 direct(Routing/路由)

可以将根据不同的路由规则分发消息,很灵活,消费者需要哪种就订阅哪种消息。

在这里插入图片描述
在这里插入图片描述
RabbitDirectConfiguration

package com.student.rabbit.direct;

import org.springframework.amqp.core.AnonymousQueue;
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;

/**
 * Create by zjg on 2024/3/10
 */
@Configuration
public class RabbitDirectConfiguration {
    @Bean
    public DirectExchange direct() {
        return new DirectExchange("sys.direct");
    }

    private static class ReceiverConfig {
        @Bean
        public Queue directQueue1() {
            return new AnonymousQueue();
        }
        @Bean
        public Queue directQueue2() {
            return new AnonymousQueue();
        }
        @Bean
        public Binding bindingDirect1a(DirectExchange direct,Queue directQueue1) {
            return BindingBuilder.bind(directQueue1).to(direct).with("orange");
        }
        @Bean
        public Binding bindingDirect1b(DirectExchange direct,Queue directQueue1) {
            return BindingBuilder.bind(directQueue1).to(direct).with("black");
        }
        @Bean
        public Binding bindingDirect2a(DirectExchange direct,Queue directQueue2) {
            return BindingBuilder.bind(directQueue2).to(direct).with("green");
        }
        @Bean
        public Binding bindingDirect2b(DirectExchange direct,Queue directQueue2) {
            return BindingBuilder.bind(directQueue2).to(direct).with("black");
        }
    }
}


DirectProducer

package rabbit.direct;

import com.student.SpringbootStart;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.amqp.core.DirectExchange;
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.concurrent.atomic.AtomicInteger;

/**
 * Create by zjg on 2024/3/10
 */
@RunWith(SpringRunner.class)
@SpringBootTest(classes = SpringbootStart.class)
public class DirectProducer {
    @Autowired
    private RabbitTemplate template;
    @Autowired
    private DirectExchange direct;
    private final String[] keys = {"orange", "black", "green"};
    @Test
    public void send() {
        AtomicInteger count = new AtomicInteger(0);
        for (int i = 0; i < keys.length; i++) {
            StringBuilder builder = new StringBuilder("Hello to ");
            String key = keys[count.getAndIncrement()];
            builder.append(" "+key);
            String message = builder.toString();
            template.convertAndSend(direct.getName(), key, message);
            System.out.println(" [x] Sent '" + message + "'");
        }
    }
}

DirectConsumer

package com.student.rabbit.direct;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * Create by zjg on 2024/3/10
 */
@Component
public class DirectConsumer {
    private static final Logger log = LoggerFactory.getLogger(DirectConsumer.class);
    @RabbitListener(queues = "#{directQueue1.name}")
    public void receive1(String message){
        log.debug("receive1:"+message);
    }
    @RabbitListener(queues = "#{directQueue2.name}")
    public void receive2(String message){
        log.debug("receive2:"+message);
    }
}

共发送了3条消息,有两个队列都绑定了black,所以black的消息消费2次
在这里插入图片描述

2.3 Topics(主题)

主题模式在路由的基础上增加了routingKey的模糊匹配。
*(星)可以代替一个词。
#(hash)可以代替零个或多个单词。

在这里插入图片描述
RabbitTopicConfiguration

package com.student.rabbit.topic;

import org.springframework.amqp.core.AnonymousQueue;
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;

/**
 * Create by zjg on 2024/3/10
 */
@Configuration
public class RabbitTopicConfiguration {
    @Bean
    public TopicExchange topic() {
        return new TopicExchange("sys.topic");
    }

    private static class ReceiverConfig {
        @Bean
        public Queue topicQueue1() {
            return new AnonymousQueue();
        }
        @Bean
        public Queue topicQueue2() {
            return new AnonymousQueue();
        }
        @Bean
        public Binding bindingTopic1a(TopicExchange topic,Queue topicQueue1) {
            return BindingBuilder.bind(topicQueue1).to(topic).with("*.orange.*");
        }
        @Bean
        public Binding bindingTopic1b(TopicExchange topic,Queue topicQueue1) {
            return BindingBuilder.bind(topicQueue1).to(topic).with("*.*.rabbit");
        }
        @Bean
        public Binding bindingTopic2a(TopicExchange topic,Queue topicQueue2) {
            return BindingBuilder.bind(topicQueue2).to(topic).with("lazy.#");
        }
        @Bean
        public Binding bindingTopic2b(TopicExchange topic,Queue topicQueue2) {
            return BindingBuilder.bind(topicQueue2).to(topic).with("quick.brown.*");
        }
    }
}


TopicProducer

package rabbit.topic;

import com.student.SpringbootStart;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.amqp.core.TopicExchange;
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.concurrent.atomic.AtomicInteger;

/**
 * Create by zjg on 2024/3/10
 */
@RunWith(SpringRunner.class)
@SpringBootTest(classes = SpringbootStart.class)
public class TopicProducer {
    @Autowired
    private RabbitTemplate template;
    @Autowired
    private TopicExchange topic;
    private final String[] keys = {"quick.orange.rabbit", "lazy.orange.elephant", "quick.orange.fox",
            "lazy.brown.fox", "lazy.pink.rabbit", "quick.brown.fox"};
    @Test
    public void send() {
        AtomicInteger count = new AtomicInteger(0);
        for (int i = 0; i < keys.length; i++) {
            StringBuilder builder = new StringBuilder("Hello to ");
            String key = keys[count.getAndIncrement()];
            builder.append(" "+key);
            String message = builder.toString();
            template.convertAndSend(topic.getName(), key, message);
            System.out.println(" [x] Sent '" + message + "'");
        }
    }
}

TopicConsumer

package com.student.rabbit.topic;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * Create by zjg on 2024/3/10
 */
@Component
public class TopicConsumer {
    private static final Logger log = LoggerFactory.getLogger(TopicConsumer.class);
    @RabbitListener(queues = "#{topicQueue1.name}")
    public void receive1(String message){
        log.debug("receive1:"+message);
    }
    @RabbitListener(queues = "#{topicQueue2.name}")
    public void receive2(String message){
        log.debug("receive2:"+message);
    }
}

队列1匹配了中间值为orange和rabbit结尾的消息,队列2匹配了lazy开头和quick.brown开头的消息
在这里插入图片描述

2.4 Headers

关于headers模式,在官方没有找到文档,但包里还有,索性还是写一下吧。

RabbitHeadersConfiguration

package com.student.rabbit.headers;

import org.springframework.amqp.core.AnonymousQueue;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.HeadersExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.HashMap;
import java.util.Map;

/**
 * Create by zjg on 2024/3/10
 */
@Configuration
public class RabbitHeadersConfiguration {
    @Bean
    public HeadersExchange headers() {
        return new HeadersExchange("sys.headers");
    }

    private static class ReceiverConfig {
        @Bean
        public Queue headersQueue1() {
            return new AnonymousQueue();
        }
        @Bean
        public Queue headersQueue2() {
            return new AnonymousQueue();
        }
        @Bean
        public Queue headersQueue3() {
            return new AnonymousQueue();
        }
        @Bean
        public Binding bindingHeaders1(HeadersExchange headers,Queue headersQueue1) {
            Map<String,Object> headerValue=new HashMap<>();
            headerValue.put("user","sys");
            return BindingBuilder.bind(headersQueue1).to(headers).whereAll(headerValue).match();
        }
        @Bean
        public Binding bindingHeaders2(HeadersExchange headers,Queue headersQueue2) {
            Map<String,Object> headerValue=new HashMap<>();
            headerValue.put("user","admin");
            return BindingBuilder.bind(headersQueue2).to(headers).whereAll(headerValue).match();
        }
        @Bean
        public Binding bindingHeaders3(HeadersExchange headers,Queue headersQueue3) {
            return BindingBuilder.bind(headersQueue3).to(headers).where("user").exists();
        }
    }
}

HeadersProducer

package rabbit.headers;

import com.student.SpringbootStart;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.amqp.core.HeadersExchange;
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.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * Create by zjg on 2024/3/10
 */
@RunWith(SpringRunner.class)
@SpringBootTest(classes = SpringbootStart.class)
public class HeadersProducer {
    @Autowired
    private RabbitTemplate template;
    @Autowired
    private HeadersExchange headers;
    private final String[] keys = {"sys", "admin"};
    @Test
    public void send() {
        AtomicInteger count = new AtomicInteger(0);
        for (int i = 0; i < keys.length; i++) {
            StringBuilder builder = new StringBuilder("Hello to ");
            String key = keys[count.getAndIncrement()];
            builder.append(" "+key);
            MessageProperties messageProperties=new MessageProperties();
            messageProperties.setHeader("user",key);
            Message message = MessageBuilder.withBody(builder.toString().getBytes()).andProperties(messageProperties).build();
            template.send(headers.getName(), "", message);
            System.out.println(" [x] Sent '" + message + "'");
        }
    }
}

HeadersConsumer

package com.student.rabbit.headers;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * Create by zjg on 2024/3/10
 */
@Component
public class HeadersConsumer {
    private static final Logger log = LoggerFactory.getLogger(HeadersConsumer.class);
    @RabbitListener(queues = "#{headersQueue1.name}")
    public void receive1(Message message){
        log.debug("receive1:"+new String(message.getBody()));
    }
    @RabbitListener(queues = "#{headersQueue2.name}")
    public void receive2(Message message){
        log.debug("receive2:"+new String(message.getBody()));
    }
    @RabbitListener(queues = "#{headersQueue3.name}")
    public void receive3(Message message){
        log.debug("receive3:"+new String(message.getBody()));
    }
}

第一个队列接收sys消息,第二个队列接收admin消息,第三个队列只要包含user头的消息都接收。
在这里插入图片描述


总结

回到顶部
安装看这里
官方文档
官方网站
其他项目,可参考官方案例
路漫漫其修远兮,吾将上下而求索。

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

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

相关文章

第十五届蓝桥杯模拟赛(第三期)

大家好&#xff0c;我是晴天学长&#xff0c;本次分享&#xff0c;制作不易&#xff0c;本次题解只用于学习用途&#xff0c;如果有考试需要的小伙伴请考完试再来看题解进行学习&#xff0c;需要的小伙伴可以点赞关注评论一波哦&#xff01;蓝桥杯省赛就要开始了&#xff0c;祝…

【谈一谈】并发_Synchronized

Synchronized 又到周末了,最近的话(有点子小日子不好过,哈哈哈!~)但是,我还是报之以歌哈哈哈 本次写关于并发_Synchronized的优化以及底层实现原理 说说心里话~其实是非常的累,原因应该怎么说呢?我发现自己在如今的这家公司,我处于一种活多钱少以及关键现在给的或自己不想干,因…

【HarmonyOS】ArkTS-联合类型

目录 联合类型实例 联合类型 联合类型是一种灵活的数据类型&#xff0c;它修饰的变量可以存储不同类型的数据。 语法&#xff1a;let 变量: 类型1 | 类型2 | 类型3 值 基于联合类型&#xff0c;变量可存不同类型数据 实例 // 需求&#xff1a;定义一个变量&#xff0c;存放…

C语言---单身狗问题

1.单身狗初阶 这个题目就是数组里面有一串数字&#xff0c;都是成对存在的&#xff0c;只有一个数字只出现了一次&#xff0c;请你找出来 &#xff08;1&#xff09;异或是满足交换律的&#xff0c;两个相同的数字异或之后是0&#xff1b; &#xff08;2&#xff09;让0和每个…

JDBC和连接池

JDBC和连接池 大纲 JDBC连接数据库的方式 具体案例 JDBC 需求&#xff1a;满足Java程序能对多个不同的数据库进行操作&#xff0c;而创建了一种接口&#xff0c;实现对数据库的规范 连接数据库的方式 1.方法1 先创建一个Driver对象&#xff0c;然后设置连接到的数据…

操作系统常见问题

操作系统常见问题 调度相关调度算法进程、线程、协程 同步相关进程间通信方式死锁&#xff08;deadlocks&#xff09;是指两个或多个进程在等待对方释放资源时发生的一种状态。操作系统原子操作多线程锁 内存相关虚拟内存页表用户空间分布线程切换上下文线程拥有哪些资源栈中主…

双向数据绑定:Vue.js的魔法背后

&#x1f90d; 前端开发工程师、技术日更博主、已过CET6 &#x1f368; 阿珊和她的猫_CSDN博客专家、23年度博客之星前端领域TOP1 &#x1f560; 牛客高级专题作者、打造专栏《前端面试必备》 、《2024面试高频手撕题》 &#x1f35a; 蓝桥云课签约作者、上架课程《Vue.js 和 E…

python单例模式应用之pymongo连接

文章目录 单例模式介绍模块简介安装简单的连接使用单例模式的连接单例类的实现配置的使用单例模式的测试 单例连接的调用 https://gitee.com/allen-huang/python 单例模式介绍 适用场景&#xff1a; 单例模式只允许创建一个对象&#xff0c;因此节省内存&#xff0c;加快对象访…

网页设计中通过css在一个固定宽度的div容器中让一行超出的文本隐藏并省略掉

实现效果&#xff1a; 实现的关键css&#xff1a; overflow&#xff1a;hidden&#xff1b;这个表示超出容器的内容进行隐藏 white-space&#xff1a;nowrap&#xff1b;表示文本不断行显示 text-overflow&#xff1a;ellipsis&#xff1b;表示超出的部分用省略号进行表示 …

定制repo(不再切换python和google源)

文章目录 定制repo&#xff08;不再切换python和google源&#xff09;前言各用各的repo定制repo2/repo3源码自动识别repo2/repo3项目完整解决方案&#xff1a; 定制repo&#xff08;不再切换python和google源&#xff09; 众知&#xff0c;Android/AOSP/ROM系统开发&#xff0c…

C语言-写一个简单的Web服务器(一)

基于TCP的web服务器 概述 C语言可以干大事&#xff0c;我们基于C语言可以完成一个简易的Web服务器。当你能够自行完成web服务器&#xff0c;你会对C语言有更深入的理解。对于网络编程&#xff0c;字符串的使用&#xff0c;文件使用等等都会有很大的提高。 关于网络的TCP协议在…

太长不看!公众号文章AI省流助手,从文章直接跳转总结!

大家好啊&#xff0c;我是豆小匠。 好久不见&#xff0c;最近在完善独立开发的小程序&#xff1a;豆流便签。 这期来分享新开发的一个功能&#xff1a;公众号文章直接跳转AI总结&#xff0c;并提供保存便签功能。 1. 前置条件 只支持解析公众号文章。只支持解析文字&#xf…

基于神经网络的偏微分方程求解器再度取得突破,北大字节的研究成果入选Nature子刊

目录 一.引言:神经网络与偏微分方程 二.如何基于神经网络求解偏微分方程 1.简要概述 2.基于神经网络求解偏微分方程的三大方向 2.1数据驱动 基于CNN 基于其他网络 2.2物理约束 PINN 基于 PINN 可测量标签数据 2.3物理驱动(纯物理约束) 全连接神经网路(FC-NN) CN…

STM32CubeMX学习笔记15---CAN总线

1、CAN简介 CAN总线网络的结构有闭环和开环两种形式 闭环结构的CAN总线网络&#xff0c;总线两端各连接一个1202的电阻。这种CAN总线网络由ISO11898标准定义&#xff0c;是高速、短距离的CAN网络&#xff0c;通信速率为125kbit/s到1Mbit/s。在1Mbit/s通信速率时&#x…

IOS使用Unity容器动态加载3D模型

项目背景 我们的APP是一个数字藏品平台,里面的很多藏品需要展示3D模型,3D模型里面可能会包含场景,动画,交互。而对应3D场景来说,考虑到要同时支持iOS端,安卓端,Unity是个天然的优秀方案。 对于Unity容器来说,需要满足如下的功能: 1.在APP启动时,需要满足动态下载最…

【开源】SpringBoot框架开发软件学院思政案例库系统

目录 一、摘要1.1 项目介绍1.2 项目录屏 二、功能模块2.1 系统管理员2.2 普通教师 三、系统展示四、核心代码4.1 查询思政案例4.2 审核思政案例4.3 查询思政课程4.4 思政案例点赞4.5 新增思政案例评语 五、免责说明 一、摘要 1.1 项目介绍 基于JAVAVueSpringBootMySQL的软件学…

OCP Java17 SE Developers 复习题09

答案 A, E. For the first scenario, the answer needs to implement List because the scenario allows duplicates, narrowing it down to options A and D. Option A is a better answer than option D because LinkedList is both a List and a Queue, and you just nee…

2024年【化工自动化控制仪表】新版试题及化工自动化控制仪表考试试题

题库来源&#xff1a;安全生产模拟考试一点通公众号小程序 化工自动化控制仪表新版试题是安全生产模拟考试一点通总题库中生成的一套化工自动化控制仪表考试试题&#xff0c;安全生产模拟考试一点通上化工自动化控制仪表作业手机同步练习。2024年【化工自动化控制仪表】新版试…

Go语言必知必会100问题-20 切片操作实战

前言 有很多gopher将切片的length和capacity混淆&#xff0c;没有彻底理清这两者的区别和联系。理清楚切片的长度和容量这两者的关系&#xff0c;有助于我们合理的对切片进行初始化、通过append追加元素以及进行复制等操作。如果没有深入理解它们&#xff0c;缺少高效操作切片…

如何查看centos7中启动了几个nginx

在 CentOS 7 中&#xff0c;最常用的几种方法如下&#xff1a; 1. 使用 ps 命令 ps 命令可以用来显示当前系统中正在运行的进程。要查看所有 Nginx 进程&#xff0c;可以使用以下命令&#xff1a; ps -ef | grep nginx这个命令会列出所有包含“nginx”字符串的进程。输出中会…