I have trouble sending NGSI/XML formatted events to my Proton-CEP GE. The use case is that I will need Orion to send events to CEP.
Orion is configured to send events to Proton, which are correctly received. However, Proton reports NullPointerException
when it receives them.
The output from catalina.out is:
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
Sending the following JSON event directly to 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...
However, sending it in NGSI/XML produced a NullPointer Exception as above. The sent message is:
<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>
Note: I have also tried sending the message found in the documentation and I get the same NullPointerException, so I know it is not a XML formatting issue.
What is the reason phqp the JSON objects are accepted, but the NGSI/XML fail?
When NGSI/xml messages are parsed by the CEP, there is a translation process between the NGSI message and the CEP input event.
The matching input event defined in the CEP must have the name <entity type>ContextUpdate
which is DeviceContextUpdate
in your case
This input event must have the following attributes:
Details and example can be found in the CEP user guide appendix