Browse Source

修复mqtt 自注册可能失效问题

zhou-hao 4 years ago
parent
commit
c9fda0f30c

+ 3 - 1
jetlinks-components/network-component/mqtt-component/src/main/java/org/jetlinks/community/network/mqtt/gateway/device/MqttServerDeviceGateway.java

@@ -241,7 +241,9 @@ class MqttServerDeviceGateway implements DeviceGateway, MonitorSupportDeviceGate
                         if (anotherSession == null) {
                             return registry
                                 .getDevice(msg.getDeviceId())
-                                .flatMap(device -> handleMessage(device.getDeviceId(), device, msg, session));
+                                .map(device -> handleMessage(device.getDeviceId(), device, msg, session))
+                                .defaultIfEmpty(Mono.defer(()->handleMessage(msg.getDeviceId(), operator, msg, session)))
+                                .flatMap(Function.identity());
                         }
                     }
                 }