因项目需要用到MQTT,一番折腾,水平有限,请大佬多多指点。
这里MQTT我用的是ActiveMQ,安装方法见我的另一篇文章:https://blog.youkuaiyun.com/w979000397/article/details/104048176
Spring我用的是5.1.6,在与MQTT集成上4和5有些不同,个人感觉5稍微简单一些,先来看看官方的说明:https://docs.spring.io/spring-integration/reference/html/mqtt.html
1.集成需要的jar包
org.eclipse.paho.client.mqttv3-1.2.1.jar
spring-integration-mqtt-5.1.6.RELEASE.jar
spring-integration-core-5.1.6.RELEASE.jar
spring-messaging-5.1.6.RELEASE.jar
reactive-streams-1.0.3.jar
reactor-core-3.2.3.RELEASE.jar
2.spring-mqtt.xml配置
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-mqtt="http://www.springframework.org/schema/integration/mqtt"
xsi:schemaLocation="
http://www.springframework.org/schema/integration http://www.springframework.org