27 changed files with 669 additions and 603 deletions
@ -1,4 +1,4 @@ |
|||||
package com.huaxing.mqtt.constant; |
package com.huaxing.common.constant; |
||||
/** |
/** |
||||
* 常量 |
* 常量 |
||||
*/ |
*/ |
@ -1,4 +1,4 @@ |
|||||
package com.huaxing.data.util; |
package com.huaxing.common.util; |
||||
|
|
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
import com.fasterxml.jackson.annotation.JsonInclude; |
||||
import com.fasterxml.jackson.core.JsonProcessingException; |
import com.fasterxml.jackson.core.JsonProcessingException; |
@ -1,6 +1,6 @@ |
|||||
package com.huaxing.mqtt.config; |
package com.huaxing.mqtt.config; |
||||
|
|
||||
import com.huaxing.mqtt.constant.MqttConstant; |
import com.huaxing.common.constant.MqttConstant; |
||||
import com.huaxing.mqtt.processor.MqttMessageReceiver; |
import com.huaxing.mqtt.processor.MqttMessageReceiver; |
||||
import lombok.extern.slf4j.Slf4j; |
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.context.annotation.Bean; |
import org.springframework.context.annotation.Bean; |
@ -1,6 +1,6 @@ |
|||||
package com.huaxing.mqtt.config; |
package com.huaxing.mqtt.config; |
||||
|
|
||||
import com.huaxing.mqtt.constant.MqttConstant; |
import com.huaxing.common.constant.MqttConstant; |
||||
import jakarta.annotation.Resource; |
import jakarta.annotation.Resource; |
||||
import lombok.AllArgsConstructor; |
import lombok.AllArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
import lombok.extern.slf4j.Slf4j; |
@ -0,0 +1,61 @@ |
|||||
|
package com.huaxing.mqtt.processor; |
||||
|
|
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.messaging.MessageHandler; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
//import org.springframework.integration.mqtt.support.MqttHeaders;
|
||||
|
//import org.springframework.messaging.Message;
|
||||
|
//import org.springframework.messaging.MessageHeaders;
|
||||
|
//import org.springframework.messaging.MessagingException;
|
||||
|
//import org.springframework.scheduling.annotation.Async;
|
||||
|
//import java.util.concurrent.CompletableFuture;
|
||||
|
|
||||
|
/** |
||||
|
* 消费者处理器 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@Component |
||||
|
@SuppressWarnings("all") |
||||
|
public abstract class MqttMessageReceiver implements MessageHandler { |
||||
|
|
||||
|
// 获取消息接口
|
||||
|
// public abstract String getMessage(String payload);
|
||||
|
|
||||
|
// /**
|
||||
|
// * 消息处理
|
||||
|
// *
|
||||
|
// * @param message 消息
|
||||
|
// * @throws MessagingException 消息异常
|
||||
|
// */
|
||||
|
// @Override
|
||||
|
// @Async("handleMessage")
|
||||
|
// public void handleMessage(Message<?> message) throws MessagingException {
|
||||
|
// try {
|
||||
|
// // 获取消息Topic
|
||||
|
// MessageHeaders headers = message.getHeaders();
|
||||
|
// String topic = String.valueOf(headers.get(MqttHeaders.RECEIVED_TOPIC));
|
||||
|
// log.info("[获取到的消息的topic]:{} ", topic);
|
||||
|
// // 获取消息体
|
||||
|
// String payload = (String) message.getPayload();
|
||||
|
// log.info("[获取到的消息的payload]:{} ", payload);
|
||||
|
// // 数据库入库消息
|
||||
|
// if (topic.contains("iot/test1/in-storage")) {
|
||||
|
// // 模拟1000000条数据入库
|
||||
|
// log.info("接收到iot/test1/in-storage的消息啦,快去处理");
|
||||
|
// getMessage(payload);
|
||||
|
//// long l = System.currentTimeMillis();
|
||||
|
//// System.currentTimeMillis();
|
||||
|
//// CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
|
||||
|
////// analysisService.parseStoreData(payload);
|
||||
|
//// });
|
||||
|
//// long l1 = System.currentTimeMillis();
|
||||
|
//// log.info("入库完成,耗时:{}", l1 - l);
|
||||
|
//// analysisService.parseStoreData(payload);
|
||||
|
// } else if (topic.contains("table-update/")){} // TODO 表更新topic
|
||||
|
// } catch (Exception e) {
|
||||
|
// log.error(e.toString());
|
||||
|
// }
|
||||
|
// }
|
||||
|
|
||||
|
} |
||||
|
|
@ -1,8 +0,0 @@ |
|||||
________ ________ _________ ________ ________ _________ ________ ________ ________ ________ _______ |
|
||||
|\ ___ \|\ __ \|\___ ___\\ __ \ |\ ____\|\___ ___\\ __ \|\ __ \|\ __ \|\ ____\|\ ___ \ |
|
||||
\ \ \_|\ \ \ \|\ \|___ \ \_\ \ \|\ \ ____________\ \ \___|\|___ \ \_\ \ \|\ \ \ \|\ \ \ \|\ \ \ \___|\ \ __/| |
|
||||
\ \ \ \\ \ \ __ \ \ \ \ \ \ __ \|\____________\ \_____ \ \ \ \ \ \ \\\ \ \ _ _\ \ __ \ \ \ __\ \ \_|/__ |
|
||||
\ \ \_\\ \ \ \ \ \ \ \ \ \ \ \ \ \|____________|\|____|\ \ \ \ \ \ \ \\\ \ \ \\ \\ \ \ \ \ \ \|\ \ \ \_|\ \ |
|
||||
\ \_______\ \__\ \__\ \ \__\ \ \__\ \__\ ____\_\ \ \ \__\ \ \_______\ \__\\ _\\ \__\ \__\ \_______\ \_______\ |
|
||||
\|_______|\|__|\|__| \|__| \|__|\|__| |\_________\ \|__| \|_______|\|__|\|__|\|__|\|__|\|_______|\|_______| |
|
||||
\|_________| |
|
Loading…
Reference in new issue