2017-02-23 64 views
0

使用CEP我試圖做一個質子和獵戶座之間溝通的基本示例。 我只是想讓質子接收來自Orion的溫度通知,並在溫度值超過或等於20時發送更改一個布爾屬性的有效載荷。CEP 5.4.3,不觸發基本條件

這是我使用的定義。

{ 
    "epn": 
    { 
     "events": 
     [ 
      { 
       "name": "TemperatureContextUpdate", 
       "attributes": 
       [ 
        { 
         "dimension": 0, 
         "description": "The certainty that this event happen (value between 0 to 1)", 
         "name": "Certainty", 
         "defaultValue": "1", 
         "type": "Double" 
        }, 
        { 
         "dimension": 0, 
         "description": "No value means it equals the event detection time, other option is to use one of the defined distribution functions with parameters", 
         "name": "OccurrenceTime", 
         "type": "Date" 
        }, 
        { 
         "dimension": 0, 
         "name": "ExpirationTime", 
         "type": "Date" 
        }, 
        { 
         "dimension": 0, 
         "description": "The cost of this event occurrence. Negative if this is an opportunity", 
         "name": "Cost", 
         "type": "Double" 
        }, 
        { 
         "dimension": 0, 
         "description": "Used in case the this event occur within an interval", 
         "name": "Duration", 
         "defaultValue": "0", 
         "type": "Double" 
        }, 
        { 
         "dimension": "0", 
         "name": "entityId", 
         "type": "String" 
        }, 
        { 
         "dimension": "0", 
         "name": "entityType", 
         "type": "String" 
        }, 
        { 
         "dimension": "0", 
         "name": "temperature", 
         "type": "Integer" 
        }, 
        { 
         "dimension": "0", 
         "name": "chaud", 
         "type": "Boolean" 
        } 
       ], 
       "createdDate": "Wed Feb 22 2017" 
      }, 
      { 
       "name": "Out_TemperatureContextUpdate", 
       "attributes": 
       [ 
        { 
         "dimension": 0, 
         "description": "The certainty that this event happen (value between 0 to 1)", 
         "name": "Certainty", 
         "defaultValue": "1", 
         "type": "Double" 
        }, 
        { 
         "dimension": 0, 
         "description": "No value means it equals the event detection time, other option is to use one of the defined distribution functions with parameters", 
         "name": "OccurrenceTime", 
         "type": "Date" 
        }, 
        { 
         "dimension": 0, 
         "name": "ExpirationTime", 
         "type": "Date" 
        }, 
        { 
         "dimension": 0, 
         "description": "The cost of this event occurrence. Negative if this is an opportunity", 
         "name": "Cost", 
         "type": "Double" 
        }, 
        { 
         "dimension": 0, 
         "description": "Used in case the this event occur within an interval", 
         "name": "Duration", 
         "defaultValue": "0", 
         "type": "Double" 
        }, 
        { 
         "dimension": "0", 
         "name": "entityId", 
         "type": "String" 
        }, 
        { 
         "dimension": "0", 
         "name": "entityType", 
         "type": "String" 
        }, 
        { 
         "dimension": "0", 
         "name": "temperature", 
         "type": "Integer" 
        }, 
        { 
         "dimension": "0", 
         "name": "chaud", 
         "type": "Boolean" 
        } 
       ], 
       "createdDate": "Wed Feb 22 2017" 
      } 
     ], 
     "name": "TemperatureDemo", 
     "consumers": 
     [ 
      { 
       "events": 
       [ 
        { 
         "name": "Out_TemperatureContextUpdate" 
        } 
       ], 
       "name": "Consumer_Rest", 
       "properties": 
       [ 
        { 
         "name": "URL", 
         "value": "http://172.17.0.3:1026/v2/entities" 
        }, 
        { 
         "name": "contentType", 
         "value": "application/json" 
        }, 
        { 
         "name": "formatter", 
         "value": "json_ngsi" 
        }, 
        { 
         "name": "delimiter", 
         "value": ";" 
        }, 
        { 
         "name": "tagDataSeparator", 
         "value": "=" 
        }, 
        { 
         "name": "dateFormat", 
         "value": "dd/MM/yyyy-HH:mm:ss" 
        } 
       ], 
       "type": "Rest", 
       "createdDate": "Wed Feb 22 2017" 
      }, 
      { 
       "events": 
       [ 
        { 
         "name": "TemperatureContextUpdate" 
        } 
       ], 
       "name": "Consumer_File", 
       "properties": 
       [ 
        { 
         "name": "filename", 
         "value": "/home/work/Documents/test.txt" 
        }, 
        { 
         "name": "formatter", 
         "value": "json" 
        }, 
        { 
         "name": "delimiter", 
         "value": ";" 
        }, 
        { 
         "name": "tagDataSeparator", 
         "value": "=" 
        } 
       ], 
       "type": "File", 
       "createdDate": "Wed Feb 22 2017" 
      } 
     ], 
     "epas": 
     [ 
      { 
       "inputEvents": 
       [ 
        { 
         "instanceSelectionPolicy": "First", 
         "alias": "TemperatureContextUpdate", 
         "filterExpression": "TemperatureContextUpdate.temperature>=20", 
         "name": "TemperatureContextUpdate", 
         "consumptionPolicy": "Consume" 
        } 
       ], 
       "derivedEvents": 
       [ 
        { 
         "name": "Out_TemperatureContextUpdate", 
         "reportParticipants": false, 
         "expressions": 
         { 
          "Cost": "TemperatureContextUpdate.Cost", 
          "Certainty": "TemperatureContextUpdate.Certainty", 
          "OccurrenceTime": "TemperatureContextUpdate.OccurrenceTime", 
          "Duration": "TemperatureContextUpdate.Duration", 
          "entityId": "TemperatureContextUpdate.entityId", 
          "ExpirationTime": "TemperatureContextUpdate.ExpirationTime", 
          "chaud": "true", 
          "entityType": "TemperatureContextUpdate.entityType", 
          "temperature": "TemperatureContextUpdate.temperature" 
         } 
        } 
       ], 
       "evaluationPolicy": "Immediate", 
       "name": "EPA_Change", 
       "internalSegmentation": 
       [ 
       ], 
       "context": "always", 
       "epaType": "Basic", 
       "cardinalityPolicy": "Single", 
       "localPlacement": true, 
       "createdDate": "Wed Feb 22 2017", 
       "computedVariables": 
       [ 
       ] 
      } 
     ], 
     "optimization": 
     { 
     }, 
     "contexts": 
     { 
      "temporal": 
      [ 
       { 
        "terminators": 
        [ 
        ], 
        "neverEnding": true, 
        "atStartup": true, 
        "name": "always", 
        "type": "TemporalInterval", 
        "createdDate": "Wed Feb 22 2017", 
        "initiators": 
        [ 
        ] 
       } 
      ], 
      "segmentation": 
      [ 
      ], 
      "composite": 
      [ 
      ] 
     }, 
     "producers": 
     [ 
     ] 
    } 
} 

我嘗試創建一個文件,而第一更新收到,但這個文件總是空的,順便說一句這是我的目錄正確地創建和更改,每次我改變的定義。其餘有效載荷永遠不會像條件從未觸發一樣發送。

有效載荷我送:

{ 
"subscriptionId": "51c04a21d714fb3b37d7d5a7", 
"data": 
[ { 
"id": "temp1", 
"type": "Temperature", 
"temperature": { 
    "type":"integer", 
    "value": 28, 
    "metadata":{} 
}, 
"chaud": { 
    "type":"boolean", 
    "value": false, 
    "metadata":{} 
}, 
    "Certainty": { 
     "value": "1", 
     "type": "Float" 
    }, 
    "Cost": { 
     "value": "0", 
     "type": "Float" 
    }, 
    "Name": { 
     "value": "", 
     "type": "String" 
    }, 
    "EventSource": { 
     "value": "", 
     "type": "String" 
    }, 
    "Duration": { 
     "value": "0", 
     "type": "Float" 
    } 
} 
] 
} 

日誌catalina.out的:

INFOS:開始的活動,郵件正文的讀者 FEVR。 23,2017 11:23:35上午com.ibm.hrl.proton.webapp.providers.EventJSONNgsiMessageReader parseVTwoFormat INFOS:Event:TemperatureContextUpdate févr。 23,2017 11:23:35上午com.ibm.hrl.proton.webapp.providers.EventJSONNgsiMessageReader readFrom INFOS:事件信息正文閱讀器 févr。 23,2017 11:23:35上午com.ibm.hrl.proton.webapp.providers.EventJSONNgsiMessageReader readFrom INFOS:EventJSONNgsiMessageReader:read event TemperatureContextUpdate; ENTITYID = temp1目錄; EVENTID = ba868559-7589-4720-ab75-658b920a3f14;查特= FALSE;的EntityType =溫度; Chronon = NULL;溫度= 28; DetectionTime = 1487845415319;名稱=;確定性= 1;成本= 0;的EventSource =; OccurrenceTime = NULL;持續時間= 0;註釋=; ExpirationTime = NULL;從經紀人... févr。 23,2017 11:23:35 AM com.ibm.hrl.proton.webapp.resources.EventResource submitNewEvent INFOS:starting submitNewEvent févr。 23,2017年上午11時23分35秒com.ibm.hrl.proton.webapp.resources.EventResource submitNewEvent INFOS:發送到質子運行事件......

所以任何想法,是我的問題?

謝謝。

回答

0

你的錯誤是你發送一個空名稱的事件。 對不起,相同的信息在輸入中是重複的,但是這來自Proton和Orion之間的整合,每一個都需要不同形式的信息,並且差異沒有很好地修補。

你應該發送應包含輸入事件的名稱,這樣的輸入:

{ 
"subscriptionId": "51c04a21d714fb3b37d7d5a7", 
"data": 
[ { 
"id": "temp1", 
"type": "Temperature", 
"temperature": { 
    "type":"integer", 
    "value": "28", 
    "metadata":{} 
}, 
"chaud": { 
    "type":"boolean", 
    "value": false, 
    "metadata":{} 
}, 
    "Certainty": { 
     "value": "1", 
     "type": "Float" 
    }, 
    "Cost": { 
     "value": "0", 
     "type": "Float" 
    }, 
    "Name": { 
     "value": "TemperatureContextUpdate", 
     "type": "String" 
    }, 
    "EventSource": { 
     "value": "", 
     "type": "String" 
    }, 
    "Duration": { 
     "value": "0", 
     "type": "Float" 
    } 
} 
] 
} 

注意,name屬性現在有值「TemperatureContextUpdate」