edgexfoundry notifications 通知 例子

25 篇文章 2 订阅
3 篇文章 0 订阅

1、 订阅通知

 

 

 

要想获得通知,需要事先向edgexfoundry平台注册

 

 

 

POST TO http://localhost:48060/api/v1/subscription

 

(会保存在notifications 数据库subscription表中)



 

{

 

  "slug": "sys-admin",

 

  "receiver": "System Administrator",

 

  "subscribedCategories": [

 

    "SECURITY",

 

    "HW_HEALTH",

 

    "SW_HEALTH"

 

  ],

 

  "subscribedLabels": [

 

    "Dell",

 

    "IoT",

 

    "test"

 

  ],

 

  "channels": [

 

    {

 

      "type": "REST",

 

      "url": "http://localhost:8080/receiveData/receiveData.do"

 

    },

 

    {

 

      "type": "EMAIL",

 

      "mailAddresses": [

 

        "15599633@qq.com"

 

    }

 

}

 

 

 

用postman工具提交如下:

 

 



 

subscribedCategories可取值为:SECURITY, HW_HEALTH, SW_HEALTH

 

subscribedLabels可取值:metadata , export

 

只要有一个满足,就执行通知,如下:

 

subscriptions = subscriptionDAO

 

          .findBySubscribedCategoriesInIgnoreCaseOrSubscribedLabelsInIgnoreCase(category, labels);

 

2、手工生成通知

 

POST TO http://localhost:48060/api/v1/notification

 

(会保存在notifications 数据库notifications表中)



 

2.1 restful格式

 

{

 

  "slug": "notice-test-003",

 

  "sender": "System Management",

 

  "category": "SECURITY",

 

  "severity": "NORMAL",

 

  "contentType": "application/json",

 

  "content": "{\"pushed\":0,\"device\":\"livingroomthermostat\",\"readings\":[{\"pushed\":0,\"name\":\"temperature\",\"value\":\"72\",\"device\":\"livingroomthermostat\",\"id\":\"5bac4a0b6862bdd543eb5821\",\"created\":1538017803672,\"modified\":1538017803672,\"origin\":1471806386919},{\"pushed\":0,\"name\":\"humidity\",\"value\":\"58\",\"device\":\"livingroomthermostat\",\"id\":\"5bac4a0b6862bdd543eb5822\",\"created\":1538017803676,\"modified\":1538017803676,\"origin\":1471806386919}],\"id\":\"5bac4a0b6862bdd543eb5823\",\"created\":1538017803679,\"modified\":1538017803679,\"origin\":1471806386919}" ,

 

  "labels": [

 

    "cool",

 

    "test"

 

  ]

 

}

 

postman工具提交:

 

 

通知结果:

 

 

 

2.2 普通风格的

 

{

 

  "slug": "notice-test-004",

 

  "sender": "System Management",

 

  "category": "SECURITY",

 

  "severity": "NORMAL",

 

  "content": "fdfdfdfdfdfdfdd" ,

 

"contentType": "text/plain",

 

  "labels": [

 

    "cool",

 

    "test"

 

  ]

 

}

 

详细咨询,请联系QQ:15599633

edgexfoundry学习视频见网址:https://guqiaoit.ke.qq.com/

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

灰哥哥

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值