activeMq将mqtt发布订阅转成消息队列

1、activemq.xml置文件新增如下内容

2、mqttx测试发送:

主题(配置的模糊匹配,为了并发):VirtualTopic/device/sendData/12312

3、mqtt接收的结果

4、程序处理

package comimport cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;import org.apache.activemq.ActiveMQMessageAudit;
import org.apache.activemq.command.ActiveMQBytesMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;import javax.jms.Message;
import java.nio.charset.Charset;
import java.util.Date;@Component
public class MessageHandler {@JmsListener(destination = "deviceQueue.receiveDate", containerFactory = "queueListener", concurrency = "1-3")public void deviceMessage(ActiveMQBytesMessage message) {System.out.println(StrUtil.str(message.getContent().getData(), Charset.defaultCharset()));System.out.println("###################" + message + "###################");}
}

 控制台打印

 全量的:activemq.xml

<!--Licensed to the Apache Software Foundation (ASF) under one or morecontributor license agreements.  See the NOTICE file distributed withthis work for additional information regarding copyright ownership.The ASF licenses this file to You under the Apache License, Version 2.0(the "License"); you may not use this file except in compliance withthe License.  You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.
-->
<!-- START SNIPPET: example -->
<beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsdhttp://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd"><!-- Allows us to use system properties as variables in this configuration file --><bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"><property name="locations"><value>file:${activemq.conf}/credentials.properties</value></property></bean><!--The <broker> element is used to configure the ActiveMQ broker.--><broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="${activemq.data}"><destinationPolicy><policyMap><policyEntries><policyEntry topic=">" ><!-- The constantPendingMessageLimitStrategy is used to preventslow topic consumers to block producers and affect other consumersby limiting the number of messages that are retainedFor more information, see:http://activemq.apache.org/slow-consumer-handling.html--><pendingMessageLimitStrategy><constantPendingMessageLimitStrategy limit="1000"/></pendingMessageLimitStrategy></policyEntry></policyEntries></policyMap></destinationPolicy><!--The managementContext is used to configure how ActiveMQ is exposed inJMX. By default, ActiveMQ uses the MBean server that is started bythe JVM. For more information, see:http://activemq.apache.org/jmx.html--><managementContext><managementContext createConnector="false"/></managementContext><!--Configure message persistence for the broker. The default persistencemechanism is the KahaDB store (identified by the kahaDB tag).For more information, see:http://activemq.apache.org/persistence.html--><persistenceAdapter><kahaDB directory="${activemq.data}/kahadb"/></persistenceAdapter><!--The systemUsage controls the maximum amount of space the broker willuse before disabling caching and/or slowing down producers. For more information, see:http://activemq.apache.org/producer-flow-control.html--><systemUsage><systemUsage><memoryUsage><memoryUsage percentOfJvmHeap="70" /></memoryUsage><storeUsage><storeUsage limit="100 gb"/></storeUsage><tempUsage><tempUsage limit="50 gb"/></tempUsage></systemUsage></systemUsage><!--The transport connectors expose ActiveMQ over a given protocol toclients and other brokers. For more information, see:http://activemq.apache.org/configuring-transports.html--><transportConnectors><!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB --><transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/><transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/><transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/><transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/><transportConnector name="ws" uri="ws://0.0.0.0:61614?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/></transportConnectors><!-- destroy the spring context on shutdown to stop jetty --><shutdownHooks><bean xmlns="http://www.springframework.org/schema/beans" class="org.apache.activemq.hooks.SpringContextHook" /></shutdownHooks><!-- 消息订阅 --><destinationInterceptors><virtualDestinationInterceptor><virtualDestinations><compositeTopic name="VirtualTopic.device.sendData.*"><forwardTo><queue physicalName="deviceQueue.receiveDate" /></forwardTo></compositeTopic></virtualDestinations></virtualDestinationInterceptor></destinationInterceptors><plugins><simpleAuthenticationPlugin><users><authenticationUser username="${activemq.username}" password="${activemq.password}" groups="users,admins"/><!--<authenticationUser username="user" password="password" groups="users"/><authenticationUser username="guest" password="password" groups="guests"/> --></users></simpleAuthenticationPlugin></plugins></broker><!--Enable web consoles, REST and Ajax APIs and demosThe web consoles requires by default login, you can disable this in the jetty.xml fileTake a look at ${ACTIVEMQ_HOME}/conf/jetty.xml for more details--><import resource="jetty.xml"/></beans>
<!-- END SNIPPET: example -->

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

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

相关文章

ReactNative进阶(二十三)error: no type or protocol named ‘RCTBridgeModule’问题修复

文章目录 一、前言三、拓展阅读 一、前言 Jenkins组包RN技术栈实现的iOS应用时&#xff0c;遇到以下错误提示信息&#xff1a; error: no type or protocol named ‘RCTBridgeModule’ interface RCTEventDispatcher : NSObject <RCTBridgeModule>error: cannot find i…

【AIGC】基于深度学习的图像生成与增强技术

摘要&#xff1a; 本论文探讨基于深度学习的图像生成与增强技术在图像处理和计算机视觉领域的应用。我们综合分析了主流的深度学习模型&#xff0c;特别是生成对抗网络&#xff08;GAN&#xff09;和变分自编码器&#xff08;VAE&#xff09;等&#xff0c;并就它们在实际应用中…

嵌入式linux开发 (三十四) 内存管理2.0(6) 各种段(.code .rodata .data .bss .stack .heap)的含义

我们知道, 逻辑程序在连接的时候在elf 文件中会有 .code .rodata .data 然后在内存中才会有 .code .rodata .data那么为什么链接器在链接生成的elf文件中会有这些段呢?这涉及到链接器的历史问题

小程序性能优化

背景 在开发小程序的过程中我们发现&#xff0c;小程序的经常会遇到性能问题&#xff0c;尤其是在微信开发者工具的时候更是格外的卡&#xff0c;经过排查发现&#xff0c;卡顿的页面有这么多的js代码需要加载&#xff0c;而且都是在进入这个页面的时候加载&#xff0c;这就会…

Java架构师之路九、设计模式:常见的设计模式,如单例模式、工厂模式、策略模式、桥接模式等

目录 常见的设计模式&#xff1a; 单例模式&#xff1a; 工厂模式&#xff1a; 策略模式&#xff1a; 桥接模式&#xff1a; 责任链模式&#xff1a; Java架构师之路八、安全技术&#xff1a;Web安全、网络安全、系统安全、数据安全等-CSDN博客Java架构师之路十、框架和工…

Android 仿信号格子强度动画效果实现

效果图 在 Android 中&#xff0c;如果你想要绘制一个圆角矩形并使其居中显示&#xff0c;你可以使用 Canvas 类 drawRoundRect 方法。要使圆角矩形居中&#xff0c;你需要计算矩形的位置&#xff0c;这通常涉及到确定矩形左上角的位置&#xff08;x, y&#xff09;&#xff0…

Leetcode 第 384 场周赛题解

Leetcode 第 384 场周赛题解 Leetcode 第 384 场周赛题解题目1&#xff1a;3033. 修改矩阵思路代码复杂度分析 题目2&#xff1a;3034. 匹配模式数组的子数组数目 I思路代码复杂度分析 题目3&#xff1a;3035. 回文字符串的最大数量思路代码复杂度分析 题目4&#xff1a;3036. …

C语言标准库介绍:<string.h>

在C语言中&#xff0c;<string.h>头文件是标准库中的一个重要部分&#xff0c;它定义了一系列操作字符串和字符数组的函数。本文将详细介绍<string.h>头文件中包含的22个函数&#xff0c;并提供每个函数的完整示例代码。 简介 <string.h>头文件定义了一个变…

设计模式-工厂模式(Factory Pattern)

一、工厂模式说明 工厂模式是一种创建型设计模式&#xff0c;它提供了一种将对象的创建与使用分离的方式。工厂模式通过引入一个公共的接口来创建对象&#xff0c;而不是通过直接调用构造函数来创建对象。这样做的好处是使得代码更加灵活&#xff0c;更容易维护和扩展。 工厂模…

第3部分 原理篇2去中心化数字身份标识符(DID)(2)

3.2.2. DID相关概念 3.2.2.1. 去中心化标识符 (Decentralized identifier&#xff0c;DID) 本聪老师&#xff1a;DID有两个含义&#xff0c;一是Decentralized identity&#xff0c;就是去中心化身份&#xff0c;是广泛意义的DID。另外一个是Decentralized identifier&#xf…

Web性能优化-浏览器工作原理-MDN文档学习笔记

浏览器工作原理 查看更多学习笔记&#xff1a;GitHub&#xff1a;LoveEmiliaForever MDN中文官网 导航 导航是加载 web 页面的第一步&#xff1a;输入 URL、点击一个链接、提交表单等等 DNS查询 导航的第一步是要去寻找页面资源的位置 例如访问https://example.com&#x…

如何解决DNS解析错误故障

DNS解析错误会导致将一个域名解析为错误的IP地址&#xff0c;或者根本无法确定某个域名对应的IP地址&#xff0c;从而无法通过域名访问相应的站点&#xff0c;形成DNS解析故障。最常见的症状是访问站点对应的IP地址没有问题&#xff0c;但访问其域名时却出现错误。 DNS解析异常…

qt-动画圆圈等待-LED数字

qt-动画圆圈等待-LED数字 一、演示效果二、关键程序三、下载链接 一、演示效果 二、关键程序 #include "LedNumber.h" #include <QLabel>LEDNumber::LEDNumber(QWidget *parent) : QWidget(parent) {//设置默认宽高比setScale((float)0.6);//设置默认背景色se…

【深入了解TensorFlow】TensorFlow的安装与配置

【深入了解TensorFlow】TensorFlow的安装与配置 TensorFlow的安装与配置准备就绪:开始前的准备工作1. 确定您的硬件和操作系统2. 选择安装方式3. 创建虚拟环境(可选)安装TensorFlow使用pip安装使用conda安装从源代码编译安装配置TensorFlow导入TensorFlow模块检查安装是否成…

Oracle 表被删除或重命名后账户间的授权与同义词关系

Oracle 表被删除或重命名后账户间的授权与同义词关系 情景一、 当数据表删除后 数据表被删除后&#xff0c;同义词还是存在的&#xff0c;可以查看当前用户下查看同义词&#xff1a; -- 查看当前用户下的同义词 select * from user_synonyms但授权关系不在了&#xff0c;若重…

10 个 Linux 中超方便的 Bash 别名

1、 你有几次遇到需要解压 .tar 文件但无法记住所需的确切参数&#xff1f;别名可以帮助你&#xff01;只需将以下内容添加到 .bash_profile 中&#xff0c;然后使用 untar FileName 解压缩任何 .tar 文件。 alias untartar -zxvf 2、 下载文件时&#xff0c;如果出现问题想要…

websocket与Socket的区别

概念讲解 网络&#xff1a;通俗意义上&#xff0c;也就是连接两台计算器 五层网络模型&#xff1a;应用层、传输层、网络层、数据链路层、物理层 应用层 (application layer)&#xff1a;直接为应用进程提供服务。应用层协议定义的是应用进程间通讯和交互的规则&#xff0c;不…

明明正常,却不停return

明明正常&#xff0c;却不停return if(!is); { return ; } 熬人

应急响应速查

最重要的&#xff1a;我是谁&#xff1f;我在哪&#xff1f;别人怎么进来的&#xff1f;我就是这个被挖矿被勒索的电脑。 分析项 &#xff1a; 一、了解大概的被入侵系统情况&#xff1a; 发现时间&#xff1f;怎么发现的&#xff1f;这台机器有没有人运维&#xff1f;平时还…

排序第三篇 直接插入排序

插入排序的基本思想是&#xff1a; 每次将一个待排序的记录按其关键字的大小插入到前面已排好序的文件中的适当位置&#xff0c; 直到全部记录插入完为止。 一 简介 插入排序可分为2类 本文介绍 直接插入排序 它的基本操作是&#xff1a; 假设待排充序的记录存储在数组 R[1……