fiware - Proton-CEP 接收事件 API NGSI/XML NullPointerException

标签 fiware fiware-orion

我无法将 NGSI/XML 格式的事件发送到我的 Proton-CEP GE。用例是我需要 Orion 将事件发送到 CEP。

Orion 配置为向 Proton 发送事件,这些事件已被正确接收。然而,Proton 在收到它们时会报告 NullPointerException。

catalina.out 的输出是:

Nov 12, 2015 7:30:27 PM com.ibm.hrl.proton.webapp.providers.EventXmlNgsiMessageReader readFrom
INFO: started event message body reader
Nov 12, 2015 7:30:27 PM com.ibm.hrl.proton.webapp.providers.EventXmlNgsiMessageReader readFrom
INFO: Event: DeviceContextUpdate
Nov 12, 2015 7:30:27 PM com.ibm.hrl.proton.webapp.providers.EventXmlNgsiMessageReader readFrom
SEVERE: Could not parse XML NGSI event java.lang.NullPointerException, reason: null
 last attribute name: null last value: null
Nov 12, 2015 7:30:27 PM com.ibm.hrl.proton.webapp.providers.EventXmlNgsiMessageReader readFrom
INFO: finished event message body reader
Nov 12, 2015 7:30:27 PM com.ibm.hrl.proton.webapp.resources.EventResource submitNewEvent
INFO: starting submitNewEvent
Nov 12, 2015 7:30:27 PM com.ibm.hrl.proton.webapp.resources.EventResource submitNewEvent
SEVERE: Could not send event, reason: java.lang.NullPointerException, message: null

将以下 JSON 事件直接发送到 CEP 是可行的:

{"Name": "Device", "datacount5": "10", "lastupdate": "12/11/2015-17:09:08"}

INFO: starting submitNewEvent
Nov 12, 2015 7:31:39 PM com.ibm.hrl.proton.router.EventRouter routeTimedObject
INFO: routeTimedObject: forwarding event Device; EventId=32314f63-75d3-489f-9d8d-dbd0ba4a42b8; Chronon=null; DetectionTime=1447353099831; Name=Device; Certainty=0.0; Cost=0.0; lastupdate=1447344548000; EventSource=; OccurrenceTime=null; datacount5=10; Annotation=; Duration=0.0; ExpirationTime=null;  to consumer...
Nov 12, 2015 7:31:39 PM com.ibm.hrl.proton.webapp.resources.EventResource submitNewEvent
INFO: events sent to proton runtime...

但是,以 NGSI/XML 发送它会产生如上所述的 NullPointer 异常。发送的消息是:

<notifyContextRequest>
  <subscriptionId>51a60c7a286043f73ce9606c</subscriptionId>
  <originator>localhost</originator>
  <contextResponseList>
    <contextElementResponse>
      <contextElement>
        <entityId type="Device" isPattern="false">
          <id>Device.imei2</id>
        </entityId>
        <contextAttributeList>
          <contextAttribute>
            <name>datacount5</name>
            <contextValue>5</contextValue>
          </contextAttribute>
        </contextAttributeList>
      </contextElement>
      <statusCode>
        <code>200</code>
        <reasonPhrase>OK</reasonPhrase>
      </statusCode>
    </contextElementResponse>
  </contextResponseList>
</notifyContextRequest>

注意:我也尝试发送 the documentation 中找到的消息我得到了相同的 NullPointerException,所以我知道这不是 XML 格式问题。

phqp JSON 对象被接受,但 NGSI/XML 失败的原因是什么?

最佳答案

当CEP解析NGSI/xml消息时,NGSI消息和CEP输入事件之间有一个转换过程。

CEP 中定义的匹配输入事件必须具有名称 <entity type>ContextUpdate这是 DeviceContextUpdate在你的情况

此输入事件必须具有以下属性:

  • entityId – 字符串类型。该属性保存消息中提供的entityId值
  • entityType – 字符串类型。该属性保存消息中提供的实体类型

详细信息和示例可以在CEP user guide appendix中找到

关于fiware - Proton-CEP 接收事件 API NGSI/XML NullPointerException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33678805/

相关文章:

fiware-orion - 固件猎户座 : return subscription id

fiware - 如何在 Orion Context Broker NGSIv2 上创建高级订阅表达式?

fiware-orion - map 查看器从上下文代理实例检索 POI

python-2.7 - Python Fiware Orion Context Broker 问题

fiware - Orion 上下文代理 - 查询

ssl - 如何使 Orion Context Broker 使用 HTTPS 通知?

fiware - 如何发送Orion中传感器的海量数据

openstack - 将 Orion 与 TROVE (Openstack) 等 DBaaS 集成

fiware - Cygnus 无法在 Cosmos 全局实例上保留数据

ssl - 获取错误 "Error loading private server key"