springboot 整合rabbitmq

springboot整合rabbitMQ 登录rabbitMQ后台。拉取rabbitMQ镜像。查看容器是否启动成功。运行rabbitMQ。安装docker参考。查看镜像是否拉取成功。第二步:生产者(publisher)创建test。新建一个父项目和两个子项目。一个为生产者、一个为消费者。我这里使用的是vm虚拟机做演示。application.yml 配置。消费者(consumer)接收代码。 阅读详情

首先导入坐标

使用 生产者:

package com.example.flyway;

import lombok.Data;
import org.junit.jupiter.api.Test;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.amqp.RabbitTemplateConfigurer;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
class FlywayApplicationTests {

    @Test
    void contextLoads() {
    }

    @Autowired
    protected RabbitTemplate rabbitTemplate;

    @Test
    public void test()
    {
        rabbitTemplate.convertAndSend("hello" , "hello world");
    }
}

如果只有生产者去生产消息, 而没有消费者去消费消息, 那么rabbitmq不会创建队列。(重点) 因为没有消费者的队列时没有意义的。

当有消费者消费时, 队列才会被创建。

是基于消费者去创建交换机

package rabbitmq;

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

@Component
@RabbitListener(queuesToDeclare = @Queue("hello"))
public class Consumer {

    @RabbitHandler
    public void receivel(String message)
    {
        System.out.println("message = " + message);
    }
}

广播模式 消费者端:

    // 广播模式
    @RabbitListener(bindings = {
            @QueueBinding(
                    value = @Queue, //创建一个临时队列  @Queue(value = "xxx" ) 创建一个具名队列
                    exchange = @Exchange(value = "交换机名称" , type="交换机类型" ) // fanout  direct topic
            )
    })
    public void receive2(String message)
    {
        System.out.println("message" + message);
    }

动态路由  消费者端:

    
    // 动态路由
    @RabbitListener(bindings = {
            @QueueBinding(
                    value = @Queue, //创建一个临时队列  @Queue(value = "xxx" ) 创建一个具名队列
                    exchange = @Exchange(value = "topic" , type="topic" ), // fanout  direct topic
                    key = {"user.save" , "user.delete"}
            )
    })
    public void receive3(String message)
    {
        System.out.println("message" + message);
    }

 

Springboot 实践(13)spring boot 整合RabbitMq 1、创建web project项目,名称为“SpringbootAction-RabbitMQ” 2、修改pom.xml文件,添加amqp使用jar包 3、 修改application.xml,配置服务器RabbitMQ服务器 4、 添加RabbitMQ配置文件 5、 添加producer生产者文件 6、添加consumer消费者文件 7、测试 阅读详情

相关推荐

SpringBoot 整合 RabbitMQ

相关知识 交换器 direct:一对一 fanout:一对多 topic:一对多匹配 目标 整合 Spring boot 提供的 spring-boot-starter-amqp,实现消息发送、消息消费、确认 准备工作 安装RabbitMQ 介绍使用 Docker 方式安装,Docker 安装可以参考 https://blog.csdn.net/gongm24/article/details/...

死牛胖子的技术随笔 832

SpringBoot中配置RabbitMQ

在SpringBoot中配置RabbitMQ

CaptHua的博客 1万+

基于Windows环境的OGG远程抽取异常(经典模式)OGG-02830 Formatting error

MOS提供的解决方法,根据MOS的提示是由于使用的OGG版本太新了,经典模式下已经弃用了这种远程抽取方式。问题:Windows环境下启用远程抽取ADG备库的数据,在启动抽取进程的时候出现如下错误提示。

Mrzhou的博客 380

RabbitMQ 浅析

转载自:https://www.cnblogs.com/ityouknow/p/6120544.html RabbitMQ 是一个由 Erlang 语言开发的 AMQP(高级消息队列协议) 的开源实现。它主要是用来实现应用程序的异步和解耦,同时也能起到消息缓冲、消息分发的作用。 AMQP AMQP,即Advanced Message Queuing Protocol,高级消息队列协议,是...

Darklovy 692

PyQtWebEngine安装避坑指南:快速解决ModuleNotFoundError

本文详细解析了PyQt5开发中常见的ModuleNotFoundError: No module named 'PyQt5.QtWebEngineWidgets'错误。核心原因是PyQt5 5.11版本后,网页引擎组件被独立为PyQtWebEngine包。文章对比了退回旧版本、独立安装及使用Conda等多种解决方案,并提供了针对Windows、macOS和Linux不同平台的实战安装指南与验证方法,帮助开发者快速解决依赖问题。

weixin_29056101的博客 429

MIT IDSS深度解析:跨学科融合与系统科学实践

麻省理工学院的IDSS(Institute for Data, Systems, and Society, IDSS)是一个致力于通过先进分析方法推动教育与研究的前沿机构。它将工程学、信息科学和数据科学的方法与社会科学的分析方法相结合,以应对复杂的社会挑战。

AllenLV的博客 2089

SpringBoot整合RabbitMQ

该篇文章内容较多,包括有rabbitMq相关的一些简单理论介绍,provider消息推送实例,consumer消息消费实例,Direct、Topic、Fanout的使用,消息回调、手动确认等。 (但是关于rabbitMq的安装,就不介绍了) 在安装完rabbitMq后,输入http://ip:15672/,是可以看到一个简单后台管理界面的。 在这个界面里面我们可以做些什么? 可以手动创建虚拟host,创建用户,分配权限,创建交换机,创建队列等等,还有查看队列消息,消费效率,推送效率等等。 以上..

K_kzj_K的博客 5237

ShardingSphere分库分表教程,java后端开发面试题

???? 简介:Java领域优质创作者????、优快云哪吒公众号作者✌ 、Java架构师奋斗者???? ???? 扫描主页左侧二维码,加入群聊,一起学习、一起进步 ???? 欢迎点赞 ???? 收藏 ⭐留言 ???? 目录 一、分库分表 二、分库分表的方式 1、垂直分表 2、垂直分库 3、水平分表 4、水平分库 三、分库分表带来的问题 1、学习成本问题 2、事务问题 3、跨节点join问题 4、跨节点的count、order by、group by以及聚合函数问题 5、数据迁移、容量规划、扩

m0_64205716的博客 3020

SpringBoot中整合RabbitMQ(测试+部署上线 最完整)

包括RabbitMQ在虚拟机本地测试和部署上线通过微信小程序测试,包括Java代码使用示例,也有部署RabbitMQ中的一些困难和解决办法,和最后的解决,配置部署代码一条龙。

乄bluefox - 优快云博客 1万+

Vivado实战:UltraScale/UltraScale+器件eFUSE寄存器配置与安全编程全解析

本文详细解析了Xilinx UltraScale/UltraScale+器件中eFUSE寄存器的配置与安全编程方法。从芯片唯一身份标识到加密密钥烧录,再到用户寄存器的灵活应用和安全控制寄存器的配置技巧,全面介绍了如何利用eFUSE功能提升硬件安全性。文章还提供了JTAG接口安全管理和NKZ文件备份方案,帮助开发者避免常见陷阱,确保安全编程的可靠性。

weixin_42535703的博客 431

三菱CNC数据采集实战:从环境搭建到代码实现的完整指南

本文提供了一份完整的三菱CNC数据采集实战指南,涵盖从开发环境搭建、核心SDK获取、网络配置到基于C#和A2协议的完整代码实现。文章详细解析了初始化、连接管理、数据获取与展示四大核心模块,并分享了错误处理、性能优化及与MES系统集成的关键技巧,帮助工程师快速构建稳定可靠的工业数据采集系统。

wood5的博客 893

SpringBoot 集成 RabbitMQ

SpringBoot 集成 RabbitMQ

爱笑的boy的博客 1万+

RT-DETR算法优化改进:轻量级上采样CARAFE算子 | 注意力机制大作战

上采样操作CARAFE,具有感受野大、内容感知、轻量级、计算速度快等优点,引入RT-DETR二次创新;1)代替Upsample进行使用;

①答疑群聊服务;②YOLO大模型知识问答系统;③计算机视觉论文生成智能体; 1267

SpringBoot如何整合RabbitMQ

好久没有写博客了,终日忙于生计,真是人过30不如狗啊,但写点什么好呢?想想当年自己入门时候那痛苦的经历,还是写点优质实用的入门文章吧,既满足了自己好为人师的本性,也能给后辈提供一些帮助。今天咱们就来聊聊springboot整合rabbitmq的那些事吧。SpringBoot的风头之盛不多说了,我是在2016年首次接触springboot的,当时自己要写个APP,后台采用了springboot。当时还真是个新鲜事物,没想到以后几年的发展犹如黄河泛滥,一发不可收拾…rabbitmq官网https。...

ShuSheng007的程序人生 1万+

JavaSwing_4.2: JDialog、JOptionPane(对话框)

JDialog,对话框。使用 JDialog 类可以创建自定义有的对话框,或者调用 JOptionPane 中的多个静态方法快速创建各种标准的对话框。JOptionPane是 JavaSwing 内部已实现好的,以静态方法的形式提供调用,能够快速方便的弹出要求用户提供值或向其发出通知的标准对话框。

谢TS的博客 7万+

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

SpringBoot整合RabbitMQ案例

SpringBoot整合RabbitMQ 一 .安装RabbitMQ(Windows环境) 第一步:首先下载Erlang环境,因为RabbitMQ服务端代码是使用并发式语言Erlang编写的,安装Rabbit MQ的前提是安装Erlang。 下载地址:https://www.erlang.org/patches/otp-24.1.6 下载安装完后需要配置系统环境变量 此电脑–>鼠标右键“属性”–>高级系统设置–>环境变量–>“新建”系统环境变量 变量名:ERLANG_HOME 变

cheney6666的博客 1527

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

SpringBoot整合Rabbitmq:超详细(包括docker配置Rabbitmq的详细过程)

MQ(message queue),从字面意思上看就个 FIFO 先入先出的队列,只不过队列中存放的内容是 message 而已,它是一种具有接收数据、存储数据、发送数据等功能的技术服务。在互联网架构中,MQ 是一种非常常见的上下游“逻辑解耦+物理解耦”的消息通信服务,用于上下游传递消息。使用了 MQ 之后,消息发送上游只需要依赖 MQ,不用依赖其他服务常见的MQ消息中间件有很多,例如ActiveMQRabbitMQKafkaRocketMQ等等。

yw2490614330的博客 2909

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

MQ Springboot整合RabbitMQ

1 资源 资源信息 版本号 备注 rabbitMQ 3.6.5 IP: 192.168.51.4 springboot 2.1.5.RELEASE springboot-rabbitmq-demo 源码 下载 2 rabbitmq安装 需要安装rabbitmq,如果未安装,可参考博文: MQ RabbitMQ 单机版部署和配置 3 springboot整合 3.1 pom文件 <?xml version="1.0" encoding="UTF-8"?> <proj

小P聊技术 409

快速上手RabbitMQ及springboot快速整合RabbitMQ

Work模型的使用:多个消费者绑定到一个队列,同一条消息只会被一个消费者处理通过设置prefetch来控制消费者预取的消息数量Fanout交换机将消息路由给每一个与之绑定的队列Direct交换机根据RoutingKey判断路由给哪个队列如果多个队列具有相同的RoutingKey,则与Fanout功能类似。

2201_75442471的博客 1298

Spring boot整合RabbitMQ

目录: 一、RabbitMQ简介   RabbitMQ安装不必我多说,linux和windows环境下都可以安装,我是在windows环境下进行安装的,安装RabbitMQ之前需要先安装Erlang,因为Rabbit MQ 是建立在Erlang OTP平台上,而且安装Erlang 时要注意安装的RabbityMQ 所依赖的Erlang版本。   RabbitMQ是实现了高级消息队列协议(AMQP)的开源消息代理软件(亦称面向消息的中间件)。RabbitMQ服务器是用Erlang语言编写的,而且支持跨平台。

一个还在上学的程序缘 6581

RabbitMQ 整合 SpringBoot

大多应用中,可通过消息服务中间件来提升系统异步通信、扩展解耦能力、流量削峰消息服务中两个重要概念:消息代理(`message broker`)和目的地(`destination`)当消息发送者发送消息以后,将由消息代理接管,消息代理保证消息传递到指定目的地。消息队列主要有两种形式的目的地1. 队列(`queue`):点对点消息通信(`point-to-point`)2. 主题(`topic`):发布(`publish`)/订阅(`subscribe`)消息通信。

m0_46995061的博客 935

实战:SpringBoot与RabbitMQ整合

1.背景介绍 1. 背景介绍 随着微服务架构的普及,分布式系统的复杂性也逐渐增加。在这种架构中,消息队列成为了一种常见的解决方案,用于解耦服务之间的通信。RabbitMQ是一种流行的消息队列系统,它支持多种消息传输协议,如AMQP、MQTT、STOMP等。SpringBoot是一种简化Spring应用开发的框架,它提供了许多预配置的启动器,使得开发者可以快速搭建Spring应用。 在本文中,...

AI天才研究院 1418

SpringBoot整合实现RabbitMQ

RabbitMQ是由erlang语言开发,基于AMQP(Advanced Message Queue 高级消息队列协议)协议实现的消息队列,它是一种应用程序之间的通信方法,消息队列在分布式系统开发中应用非常广泛。创建2个springboot项目,一个 mq-rabbitmq-producer(生产者),一个mq-rabbitmq-consumer(消费者)。rabbitmq配置类:配置Exchange、Queue、以及绑定交换机。rabbitmq配置类:配置Exchange、Queue、以及绑定交换机。

weixin_39956506的博客 5351
上一篇: 消息队列 记录
下一篇: jenkins 学习
libingbojava
博客等级 码龄9年 64粉丝 111原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值