Fiware 质子CEP接收事件API NGSI/XML NullPointerException

Fiware 质子CEP接收事件API NGSI/XML NullPointerException,fiware,fiware-orion,Fiware,Fiware Orion,我无法将NGSI/XML格式的事件发送到Proton CEP GE。用例是我需要Orion将事件发送到CEP Orion配置为向Proton发送正确接收的事件。然而,质子在收到它们时会报告NullPointerException catalina.out的输出为: Nov 12, 2015 7:30:27 PM com.ibm.hrl.proton.webapp.providers.EventXmlNgsiMessageReader readFrom INFO: started event me

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

Orion配置为向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 works:

{"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>
注意:我还尝试发送在中找到的消息,得到了相同的NullPointerException,因此我知道这不是XML格式问题


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

事实证明,使用JSON REST发送事件时,事件名称与XML/NGSI格式不同

使用JSON时,事件名称与JSON对象中描述的完全相同

{"Name": "Device", "datacount5": "10"}
所以,
设备

在XML/NGSI的情况下,即使实体类型也设置为
Device
,如下所示:

<entityId type="Device" isPattern="false">
  <id>Device.imei2</id>
</entityId>

Device.imei2
事件名称转换为
DeviceContextUpdate


此信息在中提供(隐藏?)

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

CEP中定义的匹配输入事件的名称必须为
ContextUpdate
,在您的案例中为
DeviceContextUpdate

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

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

详情和示例可在

Thank you@Tal Haham中找到,我15分钟前就发现了这一点。我希望他们在文件中更清楚地标记这一点。