edgexfoundry notifications 通知 例子

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": [

 

        "[email protected]"

 

    }

 

}

 

 

 

用postman工具提交如下:

 

edgexfoundry notifications 通知 例子_第1张图片

 

edgexfoundry notifications 通知 例子_第2张图片



 

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工具提交:

 

edgexfoundry notifications 通知 例子_第3张图片

 

通知结果:

 

edgexfoundry notifications 通知 例子_第4张图片

 

edgexfoundry notifications 通知 例子_第5张图片

 

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/

你可能感兴趣的:(edgexfoundry,java,边缘计算)