提交 4f441cee authored 作者: linzhenjie's avatar linzhenjie

增加mqtt转socketio

上级 4e6492f0
......@@ -8,4 +8,5 @@ import org.springframework.messaging.handler.annotation.Header;
@MessagingGateway(defaultRequestChannel = "mqttOutboundChannel")
public interface MqttGateway {
void sendToMqtt(String data, @Header(MqttHeaders.TOPIC) String topic);
void sendToMqtt(byte[] data, @Header(MqttHeaders.TOPIC) String topic);
}
\ No newline at end of file
package tech.glinfo.enbao.modules.mqtt.controller;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
......@@ -9,7 +8,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tech.glinfo.enbao.common.annotation.Login;
import tech.glinfo.enbao.common.contants.Constants;
import tech.glinfo.enbao.common.utils.ByteUtils;
import tech.glinfo.enbao.common.utils.EncryptUtil;
import tech.glinfo.enbao.common.utils.R;
import tech.glinfo.enbao.common.utils.StringUtils;
......@@ -45,7 +44,8 @@ public class MqttController {
String topic = params.get("topic");
if(!StringUtils.isBlank(data, topic)) {
log.info("\nsend message >>>> topic : {}, data : {}", topic, data);
mqttGateway.sendToMqtt(data, topic);
byte[] datas = ByteUtils.hexStrToBinaryStr(data);
mqttGateway.sendToMqtt(datas, topic);
}
return R.ok();
}
......
......@@ -45,7 +45,9 @@ spring:
max-active: 1000 # 连接池最大连接数(使用负值表示没有限制)
max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制)
max-idle: 10 # 连接池中的最大空闲连接
min-idle: 5 # 连接池中的最小空闲连接
min-idle: 5 # 连
接池中的最小空闲连接
#MQ配置
activemq:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论