|
@@ -0,0 +1,34 @@
|
|
|
+package com.bizmatics.mhfire.service.listener;
|
|
|
+
|
|
|
+import com.bizmatics.mhfire.service.config.mqtt.MqttInConfig;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.context.annotation.Bean;
|
|
|
+import org.springframework.integration.annotation.ServiceActivator;
|
|
|
+import org.springframework.messaging.MessageHandler;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author yq
|
|
|
+ * @date 2021/11/3 8:13
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Component
|
|
|
+public class MqttListener {
|
|
|
+
|
|
|
+ public static final String MESSAGE_NAME = "messageInput";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理消息-消费者
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Bean(MESSAGE_NAME)
|
|
|
+ @ServiceActivator(inputChannel = MqttInConfig.CHANNEL_NAME_INPUT)
|
|
|
+ public MessageHandler handler() {
|
|
|
+ return message -> {
|
|
|
+ log.info("mqtt-----接受到的消息"+message);
|
|
|
+ String payload = message.getPayload().toString();
|
|
|
+ //进行接口推送
|
|
|
+
|
|
|
+ };
|
|
|
+ }
|
|
|
+}
|