SpringBoot2.0之整合ActiveMQ【发布订阅模式】

基于SpringBoot开发的ActiveMQ虚拟主题客户端(包含发布者和订阅者) 基于SpringBoot开发的ActiveMQ虚拟主题客户端,达到消费者多点消费、负载均衡和故障转移的目的。 详情可以参考这里: https://my.oschina.net/noryar/blog/1573047 https://my.oschina.net/noryar/blog/1575003 立即下载

发布订阅模式与前面的点对点模式很类似,简直一毛一样

注意:发布订阅模式 先启动消费者

公用pom:

<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.toov5</groupId>
  <artifactId>springboot-topic-producer</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.1.RELEASE</version>
    </parent>
    <!-- 管理依赖 -->
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Finchley.M7</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
        <!-- SpringBoot整合Web组件 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <!-- SpringBoot Activemq -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-activemq</artifactId>
        </dependency>
    </dependencies>
    <!-- 注意: 这里必须要添加, 否者各种依赖有问题 -->
    <repositories>
        <repository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/libs-milestone</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>
</project>

 与上一篇博客类似的:改改就欧克了 猜猜都知道该怎么玩

 yml:

spring:
  activemq:
    broker-url: tcp://192.168.91.6:61616
    user: admin
    password: admin
my_topic: springboot-topic-toov5
server:
  port: 8081

  config

package com.toov5.config;

import javax.jms.Topic;

import org.apache.activemq.command.ActiveMQTopic;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Component
public class ConfigQueue {
   @Value("${my_topic}")
   private String myTopic;
    
    //首先将队列注入到SpringBoot容器中去
    @Bean
    public Topic queue() {
        return new ActiveMQTopic(myTopic);
    } 
    
}

producer

package com.toov5.topicProducer;

import javax.jms.Topic;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class TopicProducer {
    @Autowired
    private JmsMessagingTemplate jmsMessagingTemplate;
    //把队列注入进来 
    @Autowired  //此注解默认是以类型找  在配置文件中 已经注入的  @Bean 
    private Topic topic;
    
    //每隔5s时间向队列发送消息
    @Scheduled(fixedDelay=5000)  //每间隔2s向队列发送消息
    public void send() {
        String msgString = System.currentTimeMillis()+" ";
        jmsMessagingTemplate.convertAndSend(topic,msgString);
        System.out.println("发布订阅通讯,msg"+msgString);
    }
}

创建producer maven

SpringBoot 默认开启点对点的!!!! 订阅模式需要手动!!!!!

yml中: 

#### 开启发布订阅
jms:
pub-sub-domain: true

 

yml:

spring:
  activemq:
    broker-url: tcp://192.168.91.6:61616
    user: admin
    password: admin
my_queue: springboot-queue-toov5
server:
  port: 8080  

 consumer

package com.toov5.activemqConsumer;

import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;

@Component
public class P2PConsumer {
   
    @JmsListener(destination= "${my_queue}")    //用这个注解去监听 监听的队列
    public void receiver(String msg) {
        System.out.println("消费者成功获取到生产者的消息,msg"+msg);
    }
    
    
}

启动类

package com.toov5.activemqConsumer;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class AppConsumer {

    public static void main(String[] args) {
        SpringApplication.run(AppConsumer.class, args);
    }
    
}

 先启动消费者 然后启动生产者,多开几个端口玩玩集群~

Spring Boot ActiveMQ发布/订阅消息模式原理解析 主要介绍了Spring Boot ActiveMQ发布/订阅消息模式原理解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下 立即下载

相关推荐

避坑指南:ZYNQ平台上AXI 1G/2.5G Ethernet Subsystem实现IEEE1588的5个关键点

本文详细解析了在ZYNQ平台上使用AXI 1G/2.5G以太网子系统实现IEEE1588精密时间协议(PTP)的5个关键避坑点。从硬件选型、Vivado工程配置到Linux驱动适配,提供了实战经验与优化技巧,帮助工程师在工业自动化、电力系统等场景中实现纳秒级时间同步。

weixin_30687051的博客 234

springboot整合activeMQ -- Topic模式

前言 今天和大家分享springboot整合activeMq之topic(主题) - - 发布/订阅模式,类似微信公众号,我们关注公共就可以收到消息,topic需要消费者先订阅才能收到消息,如果没有消费者订阅,生产者产生的消息就是废消息(发布/订阅模式,生产者生产了一个消息,可以由多个消费者进行消费)。本次实例支持websocket、消息重发、持久化… 版本信息:SpringBoot2.1.5 ...

上善若水滴世界 2129

arXiv订阅进阶玩法:除了邮件,还能用RSS和Python脚本打造你的专属论文追踪器

本文介绍了arXiv订阅的进阶玩法,教你如何通过RSS和Python脚本打造个性化的论文追踪器。突破传统邮件订阅的局限,实现实时更新、精准过滤和自动化管理,提升科研效率。特别适合需要高效追踪最新研究进展的学者和开发者。

weixin_26757925的博客 627

SpringBoot2.1.X 整合 ActiveMQ发布订阅消息队列(二)

一、订阅模式 生产者产生一条消息message放入一个topic中,该topic已经三个消费者订阅了,那么被放入topic中的这条消息,就会同时被这三个消费者取走(当然他们必须都处于在线状态),并进行“消费”。其实就类似现实生活中的手机接收推送。 二、订阅模式的使用场景 发布订阅模式下,当发布者消息量很大时,显然单个订阅者的处理能力是不足的。实际上现实场景中是多个订阅...

分享我的点点滴滴,在成长路上与你同行! 262

小白跑WRF第五天,安装WPS和静态地理数据

小白跑WRF第四天,安装WPS一、WPS简介二、下载和安装WPSV4.0第一步、进入Build_WRF文件夹第二步、下载WPSV4.0第三步、解压WPS安装包第四步、修改intmath.f(必须执行)第五步、安装WPS三、修改namelist.wps 一、WPS简介 二、下载和安装WPSV4.0 第一步、进入Build_WRF文件夹 cd Build_WRF 第二步、下载WPSV4.0 下载WPSV4.0的安装包有以下三种方式: 利用Linux命令下载。 进入网站https://www2.mmm.uca

weixin_42372313的博客 2万+

zemax像差参数Ray Fan/Spot Diagram/MTF/....讲解三

zemax像差参数Ray Fan/Spot Diagram/MTF/....讲解三

weixin_72050316的博客 1386

ActiveMQ和spring整合,订阅主题和消息消费

本文章适用初学ActiveMQ的统同学。 本演示为windows下进行 首先下载ActiveMQ 1.ActiveMQ地址     ActiveMQ官方网站:http://activemq.apache.org/  2.下载完成或解压到本地F:/目录下 3.启动本地ActiveMQ服务。   进入到安装目录双击activemq.bat文件启动,如果启动时窗口一闪而

ZQGBack的博客 5870

基于Simulink的电源纹波抑制仿真

电源纹波(Power Supply Ripple)是指直流电源输出中存在的交流分量。纹波的存在会导致电压波动,进而影响负载设备的性能和寿命。为了确保高质量的电源输出,通常需要设计有效的滤波电路来抑制纹波。Simulink 提供了一个强大的仿真环境,可以用来设计、分析和验证电源纹波抑制方案。本教程将详细介绍如何使用 Simulink 进行电源纹波抑制的仿真实例。通过本教程,我们详细介绍了如何使用 Simulink 进行电源纹波抑制的仿真实例。背景介绍:理解电源纹波及其对电力电子系统的影响。仿真建模过程。

xiaoheshang_123的博客 514

SpringBoot 整合 ActiveMQ,多个queue和多个topic实现,及前端VUE使用Stompjs接收

参考自:https://www.cnblogs.com/yufeng218/p/11509486.html 一、ActiveMQ简介 1). ActiveMQ ActiveMQ是Apache所提供的一个开源的消息系统,完全采用Java来实现,因此,它能很好地支持J2EE提出的JMS(Java Message Service,即Java消息服务)规范。JMS是一组Java应用程序接口,它提供消息的创建、发送、读取等一系列服务。JMS提供了一组公共应用程序接口和响应的语法,类似于Java数据库的统一访问.

erf_1012的专栏 4996

药物代谢仿真软件:PKSim_(6).案例研究与实践应用

通过本章的案例研究和实践应用,我们展示了如何利用PKSim软件构建药物动力学模型、进行参数估计、仿真预测和结果分析。这些方法不仅有助于优化药物代谢研究过程,还可以在药物研发中提供重要的数据支持。通过模型的构建和验证,我们可以更好地理解药物在体内的动态变化过程,为临床试验和药物治疗提供科学依据。

kkchenjj的博客 655

手把手教你学PCIE-- 热插拔电路设计与实现方案

PCIe热插拔(Hot-Plug)技术允许用户在系统运行时安全地插入或移除设备,而无需重启系统。本文将深入讲解热插拔电路的设计要点、关键器件选型及信号协议规范,涵盖机械结构、电气保护和电源管理三大核心模块。​。

MHD0815的博客 440

SpringBoot+ActiveMQ-发布订阅模式(消费端)

SpringBoot+ActiveMQ-发布订阅模式(消费端) Topic 主题 * 消息消费者(订阅方式)消费该消息 * 消费生产者将发布到topic中,同时有多个消息消费者(订阅)消费该消息 * 这种方式和点对点方式不同,发布到topic的消息会被所有订阅者消费 * 当生产者发布消息,不管是否有消费者,都不会保存消息,如果对订阅消息提前做了持久化操作,还是可以收到的

蚂蚁舞 895

C#上位机实战:PLC与检测设备无缝对接,构建产品质量实时判定系统

本文分享了基于C#开发的汽车零部件质量检测系统实现经验。系统采用三层架构:设备层(PLC/视觉相机/三坐标)、通信层(OPC UA/SDK/串口)和应用层(数据采集/判定/存储)。重点解决了三大技术难点:1)通过OPC UA订阅模式将PLC通信延迟从500ms降至50ms;2)反编译厂商Demo破解视觉SDK对接难题;3)采用时间戳+产品ID实现多设备数据同步。系统上线后质检人员减少67%,误判率降至0.5%,数据追溯效率显著提升。文章强调工业场景下稳定性优先于技术复杂度,实用经验值得借鉴。

这里只有干货:从 Modbus 通信到 MES 对接,从 YOLO 训练到工控机部署,带你搞定工业软件开发全流程。 799

SpringBoot2.0之整合ActiveMQ(发布订阅模式)

SpringBoot2.0之整合ActiveMQ(发布订阅模式) 发布订阅模式与前面的点对点模式很类似,简直一毛一样 注意:发布订阅模式 先启动消费者 公用pom: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" x...

art_code的博客 719

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

深度学习工具包 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")

《SpringBoot2.0 实战》系列-整合Activemq实现点对点、发布订阅模式共存、消息持久化、重试等

简介 Apache ActiveMQ是Apache软件基金会所研发的开放源代码消息中间件;由于ActiveMQ是一个纯Java程序,因此只需要操作系统支持Java虚拟机,ActiveMQ便可执行。 作用 应用解耦 异步通信 流量削峰 消息通讯 安装 提供docker的安装方式,其他方式网上也都有很多 https://blog.csdn.net/HXNLYW/article/de...

小葫芦的博客 1140

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

SpringBoot2.X学习之整合ActiveMQ实战同时支持queue以及topic

activemq是一个非常常用的消息中间件,本节课进行SpringBoot2.0整合activemq队列模式的讲解,关于activemq基本介绍网上很多,这里就不进行详细讲解了。 SpringBoot关于activemq的官网:https://docs.spring.io/spring-boot/docs/2.1.0.BUILD-SNAPSHOT/reference/htmlsingle/#bo...

袖卷笛音的博客 1282

Spring Boot 2.X - Spring Boot整合JMS之ActiveMQ(发布订阅模式)

文章目录Spring Boot 2.X - Spring Boot整合JMS之ActiveMQ1.修改配置2.订阅者3.修改接口4.启动测试5.问题?6.点对点和发布订阅共存解决6.1 新建配置类6.2 修改配置6.3 修改订阅者6.4 启动测试7.发现另一种方法7.1 修改配置7.2 注释掉配置类7.3 修改订阅者7.4 修改点对点调用方法7.5 启动测试 Spring Boot 2.X - S...

XUDC的程序人生 3235

ActiveMQ整合SpringBoot踩坑

ActiveMQ整合SpringBoot踩坑 小黄因为工作需要使用到ActiveMQ,在使用之前,小黄只掌握了RabbitMQ,因为MQ大同小异,理解了一个MQ,其他的MQ使用起来也不会有太大问题,小黄就跟着网上的帖子学会了如何使用ActiceMQ Java中使用ActiveMQ 学习嘛,肯定不能一步登天,本来小黄上来就直接ActiveMQ整合SpringBoot,搞着搞着发现整不会了,所以还是需要一步一个脚印的走,需要先在Java中学会使用ActiveMQ。 在学习过程中,因为是对比学习嘛,小黄会拿A

Yellow_Star的博客 3465

springboot 整合activemq 消息发布和订阅

1.maven依赖 <!--activemq的依赖--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-activemq&lt...

梦醒了该散了的博客 7549

SpringBoot整合activeMQ遇到的坑,以及整合案例

异常源码如下: @JmsListener(destination="mytopic") //注:此处方法不可有返回值 public String receviceTopicMsg(TextMessage tm) { String str = ""; try { str = tm.getText(); System.out.println("topic"+ tm.getTex...

那年青春,我们正好 1万+

SpringBoot整合ActiveMQ

前言 ActiveMQ 一个成熟的消息中间件,作用于系统之间的通信,降低模块与模块之间的耦合度。 消息的传递有两种类型: Queue 队列模式:一个生产者和一个消费者一一对应 Topic 发布者/订阅者模式:一个生产者对应多个消费者 本博客配置了Queue 队列模式和Topic 发布者/订阅者模式,可同时支持。 源码 GitHub地址:https://github...

我的博客 5023

《ActiveMQ系列》3.SpringBoot整合Activemq

SpringBoot整合ActiveMQ,包含发送文本消息、对象消息、持久化订阅等。

qq_45041965的博客 2236

SpringBoot 整合实现ActiveMQ

目录一、ActiveMQ介绍二、ActiveMQ安装、服务端开启2.1 安装2.2 服务端启动三、SpringBoot 整合实现ActiveMQ3.1添加依赖3.2添加配置文件(yml文件)3.3 Queue3.3.1 Queue配置3.3.2 创建生产者3.3.3 创建消费者3.3.4 启动类添加@EnableJms 注解,启动消息队列3.3.5 测试3.4 Topic3.4.1 Topic配置3.4.2 发布者3.4.3 订阅者3.4.4 测试3.4.5 创建一个配置类,在配置类中提供监听工厂配置3.4

12程序猿的博客 3679

springboot整合ActiveMQ(点对点和发布订阅)

springboot整合ActiveMQ(点对点和订阅) ActiveMQ是什么,为什么使用MQ 是基于 Java 中的 JMS 消息服务规范实现的一个消息中间件。 1.系统解耦 采用中间件之后,就可以完美解决上述中因为耦合可能导致的问题。系统 A 不用去 关心下层服务调用方的问题。 2. 异步调用 当一个请求处理需要经过 3 个系统的时候,A 和 B 系统处理时间 3ms 时间,这个是非 常快的...

Cui6023056的博客 676

SpringBoot 整合ActiveMQ

消息队列中间件是分布式系统中重要的组件,主要解决应用耦合,异步消息,流量削锋等问题。实现高性能,高可用,可伸缩和最终一致性架构。是大型分布式系统不可缺少的中间件。消息形式支持点对点和订阅-发布。 ActiveMQ是什么 ActiveMQ是消息队列技术,为解决高并发问题而生 ActiveMQ生产者消费者模型(生产者和消费者可以跨平台、跨系统) ActiveMQ支持如下两种消息传输方式 点对点模式,生产者生产了一个消息,只能由一个消费者进行消费 发布/订阅模式,生产者生产了一个消息,可以由多个消费者进行消费.

qq_38097573的博客 3614
上一篇: SpringBoot2.0之整合ActiveMQ(发布订阅模式)
下一篇: ActivemMQ之消息服务器平台(发邮件)
Art&Code
博客等级 码龄7年 77粉丝 554原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值