1. //订阅所有设备上线消息
  2. @Subscribe("/device/*/*/online")
  3. public Mono<Void> handleDeviceOnline(DeviceOnlineMessage message){
  4. //处理消息
  5. return doSomeThing();
  6. }

设备消息

topic

所有设备消息的topic的前缀均为: /device/{productId}/{deviceId}.
如:设备device-1上线消息: /device/product-1/device-1/online.
可通过通配符订阅所有设备的指定消息,如:/device/*/*/online,
或者订阅所有消息:/device/**.
::: tip
使用通配符订阅可能将收到大量的消息,请保证消息的处理速度,否则会影响系统消息吞吐量.
:::

设备Topic列表

列表中的topic已省略前缀/device/{productId}/{deviceId},使用时请加上. | topic | 类型 | 说明 | | —- | —- | —- |

| /online | DeviceOnlineMessage | 设备上线 |

| /offline | DeviceOfflineMessage | 设备离线 |

| /message/event/{eventId} | DeviceEventMessage | 设备事件 |

| /message/property/report | ReportPropertyMessage | 设备上报属性 |

| /message/property/read/reply | ReadPropertyMessageReply | 读取属性回复 |

| /message/property/write/reply | WritePropertyMessageReply | 修改属性回复 |

| /message/function/reply | FunctionInvokeMessageReply | 调用功能回复 |

| /register | DeviceRegisterMessage | 设备注册,通常与子设备消息配合使用 |

| /unregister | DeviceUnRegisterMessage | 设备注销,同上 |

| /message/children/{childrenDeviceId}/{topic} | ChildDeviceMessage | 子设备消息,{topic}为子设备消息对应的topic |

| /message/children/reply/{childrenDeviceId}/{topic} | ChildDeviceMessage | 子设备回复消息,同上 |

设备告警

在配置了设备告警规则,设备发生告警时,会发送消息到消息网关.

  1. `/rule-engine/device/alarm/{productId}/{deviceId}/{ruleId}`
  2. {
  3. "productId":"",
  4. "alarmId":"",
  5. "alarmName":"",
  6. "deviceId":"",
  7. "deviceName":"",
  8. "...":"其他从规则中获取到到信息"
  9. }

日志

系统日志

topic格式: /logging/system/{logger名称,.替换为/}/{level}.

  1. `/logging/system/org/jetlinks/pro/TestService/{level}`
  2. {
  3. "name":"org.jetlinks.pro.TestService", //logger名称
  4. "threadName":"线程名称",
  5. "level":"日志级别",
  6. "className":"产生日志的类名",
  7. "methodName":"产生日志的方法名",
  8. "lineNumber"32,//行号
  9. "message":"日志内容",
  10. "exceptionStack":"异常栈信息",
  11. "createTime":"日志时间",
  12. "context":{} //上下文信息
  13. }