Orange-OpenSource / fiware-cepheus

FIWARE Cepheus - CEP for NGSI IoT gateways
GNU General Public License v2.0
17 stars 21 forks source link

Stack Overflow Error processing rules with nested geopoint type attributes #67

Open efviodo opened 6 years ago

efviodo commented 6 years ago

I am experiencing a problem when I define geofencing rules using an attribute of type geo: point in an Event-In and then try to save this attribute together with others within another attribute in the Event-Out.

This is a concrete example of my configuration based on the "Tracker" example of the Cepheus doc. I also simplified the statements and added some extra parameters in configuration. BTW, I am using Docker Containers:

{ "service": "test", "servicePath": "/tracker", "host": "http://172.17.0.1:8080", "reset": true, "statements": [ "INSERT INTO Alert SELECT * FROM Tracker t WHERE NOT polygon({point(0, 0), point(0,50), point(50,50), point(50, 0), point(0, 0)}).contains(t.location)" ], "in": [ { "id": ".*", "type": "Tracker", "isPattern": true, "attributes": [ { "name": "time", "type": "date" }, { "name": "location", "type": "geo:point" } ], "providers": [ { "url": "http://172.17.0.1:1026", "service": "test", "servicePath": "/tracker" } ] } ], "out":[ { "id":"Fence1", "type":"Alert", "attributes":[ { "name":"time", "type":"date" }, { "name":"location", "type":"geo:point" }, { "name":"inside", "type":"boolean" }, { "name":"nested", "type":"text" } ], "brokers": [ { "url": "http://172.17.0.1:1026", "serviceName": "test", "servicePath": "/tracker", "authToken": null } ] } ] }

Then this is the Tracker1 context entity that I just created using Orion NGSI v2 API.

{ "id": "Tracker1", "type": "Tracker", "time": { "value": "2015-10-26T22:47:09Z", "type": "date" }, "location": { "value": "45.1234, 1.6543", "type": "geo:point" } }

Then if you make an UPDATE context like the following everything works fine and the Alarm is raised.

curl -X POST \ 'http://localhost:1026/v2/entities/Tracker1/attrs?type=Tracker' \ -H 'Content-Type: application/json' \ -H 'Fiware-Service: test' \ -H 'Fiware-ServicePath: /tracker' \ -d '{ "time": { "value": "2015-10-26T22:47:09Z", "type": "date" }, "location": { "value": "60.1234, 1.6543", "type": "geo:point" } }'

The problem is what happens if for some reason you want to generate a new attribute, for example an attribute called "nested" and then populate it with the entire Event In context information.

This is my configuration example in order to do so:

{ "service": "test", "servicePath": "/tracker", "host": "http://172.17.0.1:8080", "reset": true, "statements": [ "INSERT INTO Alert SELECT *, t as nested FROM Tracker t WHERE NOT polygon({point(0, 0), point(0,50), point(50,50), point(50, 0), point(0, 0)}).contains(t.location)" ], "in": [ { "id": ".*", "type": "Tracker", "isPattern": true, "attributes": [ { "name": "time", "type": "date" }, { "name": "location", "type": "geo:point" } ], "providers": [ { "url": "http://172.17.0.1:1026", "service": "test", "servicePath": "/tracker" } ] } ], "out":[ { "id":"Fence1", "type":"Alert", "attributes":[ { "name":"time", "type":"date" }, { "name":"location", "type":"geo:point" }, { "name":"inside", "type":"boolean" }, { "name":"nested", "type":"text" } ], "brokers": [ { "url": "http://172.17.0.1:1026", "serviceName": "test", "servicePath": "/tracker", "authToken": null } ] } ] }

Cepheus CEP accept the configuration files but when I make an UPDATE context request I get the following error in Cepheus CEP logs:

2018-02-15 20:43:44.508 INFO 6 --- [taskScheduler-1] c.o.cepheus.cep.SubscriptionManager : Launch of the periodic subscription task at 2018-02-15T20:43:44.508Z 2018-02-15 20:43:57.786 INFO 6 --- [nio-8080-exec-5] c.o.cepheus.cep.EsperEventProcessor : EventIn: Event{type='Tracker', values={location=POINT (60.1234 1.6543), time=Mon Oct 26 22:47:09 GMT 2015, id=Tracker1}} 2018-02-15 20:43:57.786 INFO 6 --- [nio-8080-exec-5] c.orange.cepheus.cep.EventSinkListener : EventOut: Alert / location:POINT (60.1234 1.6543) / time:Mon Oct 26 22:47:09 GMT 2015 / id:Tracker1 / inside:null / nested:{location=POINT (60.1234 1.6543), time=Mon Oct 26 22:47:09 GMT 2015, id=Tracker1} from insert into Alert select *, t as nested from Tracker as t where not polygon({point(0,0),point(0,50),point(50,50),point(50,0),point(0,0)}).contains(t.location) 2018-02-15 20:43:57.787 INFO 6 --- [nio-8080-exec-5] c.orange.cepheus.cep.EventSinkListener : [[outgoingEvents]] :::> [EventType{id='Fence1', type='Alert', isPattern=false, attributes=[Attribute{name='inside', type='boolean', metadata=[], jsonpath='null'}, Attribute{name='location', type='geo:point', metadata=[], jsonpath='null'}, Attribute{name='nested', type='text', metadata=[], jsonpath='null'}, Attribute{name='time', type='date', metadata=[], jsonpath='null'}]}, EventType{id='AutoConectadox', type='AutoConectadoEvent', isPattern=false, attributes=[Attribute{name='InputEntityFiwareService', type='text', metadata=[Metadata{name='TimeInstant', type='ISO8601', jsonpath='null'}], jsonpath='null'}, Attribute{name='InputEntityContext', type='java.util.Map', metadata=[Metadata{name='TimeInstant', type='ISO8601', jsonpath='null'}], jsonpath='null'}, Attribute{name='InputEntityFiwareServicePath', type='text', metadata=[Metadata{name='TimeInstant', type='ISO8601', jsonpath='null'}], jsonpath='null'}, Attribute{name='InputEntityId', type='text', metadata=[Metadata{name='TimeInstant', type='ISO8601', jsonpath='null'}], jsonpath='null'}, Attribute{name='InputEntityTypeId', type='text', metadata=[Metadata{name='TimeInstant', type='ISO8601', jsonpath='null'}], jsonpath='null'}, Attribute{name='RuleId', type='text', metadata=[Metadata{name='TimeInstant', type='ISO8601', jsonpath='null'}], jsonpath='null'}]}, EventType{id='OUT1', type='TempSensorAvg', isPattern=false, attributes=[Attribute{name='avgTemp', type='double', metadata=[Metadata{name='unit', type='string', jsonpath='null'}], jsonpath='null'}]}] 2018-02-15 20:43:57.792 INFO 6 --- [nio-8080-exec-6] c.o.cepheus.cep.EsperEventProcessor : EventIn: Event{type='Tracker', values={location=POINT (60.1234 1.6543), time=Mon Oct 26 22:47:09 GMT 2015, id=Tracker1}} 2018-02-15 20:43:57.793 INFO 6 --- [nio-8080-exec-6] c.orange.cepheus.cep.EventSinkListener : EventOut: Alert / location:POINT (60.1234 1.6543) / time:Mon Oct 26 22:47:09 GMT 2015 / id:Tracker1 / inside:null / nested:{location=POINT (60.1234 1.6543), time=Mon Oct 26 22:47:09 GMT 2015, id=Tracker1} from insert into Alert select *, t as nested from Tracker as t where not polygon({point(0,0),point(0,50),point(50,50),point(50,0),point(0,0)}).contains(t.location) 2018-02-15 20:43:57.793 INFO 6 --- [nio-8080-exec-6] c.orange.cepheus.cep.EventSinkListener : [[outgoingEvents]] :::> [EventType{id='Fence1', type='Alert', isPattern=false, attributes=[Attribute{name='inside', type='boolean', metadata=[], jsonpath='null'}, Attribute{name='location', type='geo:point', metadata=[], jsonpath='null'}, Attribute{name='nested', type='text', metadata=[], jsonpath='null'}, Attribute{name='time', type='date', metadata=[], jsonpath='null'}]}, EventType{id='AutoConectadox', type='AutoConectadoEvent', isPattern=false, attributes=[Attribute{name='InputEntityFiwareService', type='text', metadata=[Metadata{name='TimeInstant', type='ISO8601', jsonpath='null'}], jsonpath='null'}, Attribute{name='InputEntityContext', type='java.util.Map', metadata=[Metadata{name='TimeInstant', type='ISO8601', jsonpath='null'}], jsonpath='null'}, Attribute{name='InputEntityFiwareServicePath', type='text', metadata=[Metadata{name='TimeInstant', type='ISO8601', jsonpath='null'}], jsonpath='null'}, Attribute{name='InputEntityId', type='text', metadata=[Metadata{name='TimeInstant', type='ISO8601', jsonpath='null'}], jsonpath='null'}, Attribute{name='InputEntityTypeId', type='text', metadata=[Metadata{name='TimeInstant', type='ISO8601', jsonpath='null'}], jsonpath='null'}, Attribute{name='RuleId', type='text', metadata=[Metadata{name='TimeInstant', type='ISO8601', jsonpath='null'}], jsonpath='null'}]}, EventType{id='OUT1', type='TempSensorAvg', isPattern=false, attributes=[Attribute{name='avgTemp', type='double', metadata=[Metadata{name='unit', type='string', jsonpath='null'}], jsonpath='null'}]}] 2018-02-15 20:43:57.802 INFO 6 --- [nio-8080-exec-8] c.o.cepheus.cep.EsperEventProcessor : EventIn: Event{type='Tracker', values={location=POINT (60.1234 1.6543), time=Mon Oct 26 22:47:09 GMT 2015, id=Tracker1}} 2018-02-15 20:43:57.803 INFO 6 --- [nio-8080-exec-8] c.orange.cepheus.cep.EventSinkListener : EventOut: Alert / location:POINT (60.1234 1.6543) / time:Mon Oct 26 22:47:09 GMT 2015 / id:Tracker1 / inside:null / nested:{location=POINT (60.1234 1.6543), time=Mon Oct 26 22:47:09 GMT 2015, id=Tracker1} from insert into Alert select *, t as nested from Tracker as t where not polygon({point(0,0),point(0,50),point(50,50),point(50,0),point(0,0)}).contains(t.location) 2018-02-15 20:43:57.803 INFO 6 --- [nio-8080-exec-8] c.orange.cepheus.cep.EventSinkListener : [[outgoingEvents]] :::> [EventType{id='Fence1', type='Alert', isPattern=false, attributes=[Attribute{name='inside', type='boolean', metadata=[], jsonpath='null'}, Attribute{name='location', type='geo:point', metadata=[], jsonpath='null'}, Attribute{name='nested', type='text', metadata=[], jsonpath='null'}, Attribute{name='time', type='date', metadata=[], jsonpath='null'}]}, EventType{id='AutoConectadox', type='AutoConectadoEvent', isPattern=false, attributes=[Attribute{name='InputEntityFiwareService', type='text', metadata=[Metadata{name='TimeInstant', type='ISO8601', jsonpath='null'}], jsonpath='null'}, Attribute{name='InputEntityContext', type='java.util.Map', metadata=[Metadata{name='TimeInstant', type='ISO8601', jsonpath='null'}], jsonpath='null'}, Attribute{name='InputEntityFiwareServicePath', type='text', metadata=[Metadata{name='TimeInstant', type='ISO8601', jsonpath='null'}], jsonpath='null'}, Attribute{name='InputEntityId', type='text', metadata=[Metadata{name='TimeInstant', type='ISO8601', jsonpath='null'}], jsonpath='null'}, Attribute{name='InputEntityTypeId', type='text', metadata=[Metadata{name='TimeInstant', type='ISO8601', jsonpath='null'}], jsonpath='null'}, Attribute{name='RuleId', type='text', metadata=[Metadata{name='TimeInstant', type='ISO8601', jsonpath='null'}], jsonpath='null'}]}, EventType{id='OUT1', type='TempSensorAvg', isPattern=false, attributes=[Attribute{name='avgTemp', type='double', metadata=[Metadata{name='unit', type='string', jsonpath='null'}], jsonpath='null'}]}] 2018-02-15 20:43:57.807 INFO 6 --- [nio-8080-exec-9] c.o.cepheus.cep.EsperEventProcessor : EventIn: Event{type='Tracker', values={location=POINT (60.1234 1.6543), time=Mon Oct 26 22:47:09 GMT 2015, id=Tracker1}} 2018-02-15 20:43:57.807 INFO 6 --- [nio-8080-exec-9] c.orange.cepheus.cep.EventSinkListener : EventOut: Alert / location:POINT (60.1234 1.6543) / time:Mon Oct 26 22:47:09 GMT 2015 / id:Tracker1 / inside:null / nested:{location=POINT (60.1234 1.6543), time=Mon Oct 26 22:47:09 GMT 2015, id=Tracker1} from insert into Alert select *, t as nested from Tracker as t where not polygon({point(0,0),point(0,50),point(50,50),point(50,0),point(0,0)}).contains(t.location) 2018-02-15 20:43:57.808 INFO 6 --- [nio-8080-exec-9] c.orange.cepheus.cep.EventSinkListener : [[outgoingEvents]] :::> [EventType{id='Fence1', type='Alert', isPattern=false, attributes=[Attribute{name='inside', type='boolean', metadata=[], jsonpath='null'}, Attribute{name='location', type='geo:point', metadata=[], jsonpath='null'}, Attribute{name='nested', type='text', metadata=[], jsonpath='null'}, Attribute{name='time', type='date', metadata=[], jsonpath='null'}]}, EventType{id='AutoConectadox', type='AutoConectadoEvent', isPattern=false, attributes=[Attribute{name='InputEntityFiwareService', type='text', metadata=[Metadata{name='TimeInstant', type='ISO8601', jsonpath='null'}], jsonpath='null'}, Attribute{name='InputEntityContext', type='java.util.Map', metadata=[Metadata{name='TimeInstant', type='ISO8601', jsonpath='null'}], jsonpath='null'}, Attribute{name='InputEntityFiwareServicePath', type='text', metadata=[Metadata{name='TimeInstant', type='ISO8601', jsonpath='null'}], jsonpath='null'}, Attribute{name='InputEntityId', type='text', metadata=[Metadata{name='TimeInstant', type='ISO8601', jsonpath='null'}], jsonpath='null'}, Attribute{name='InputEntityTypeId', type='text', metadata=[Metadata{name='TimeInstant', type='ISO8601', jsonpath='null'}], jsonpath='null'}, Attribute{name='RuleId', type='text', metadata=[Metadata{name='TimeInstant', type='ISO8601', jsonpath='null'}], jsonpath='null'}]}, EventType{id='OUT1', type='TempSensorAvg', isPattern=false, attributes=[Attribute{name='avgTemp', type='double', metadata=[Metadata{name='unit', type='string', jsonpath='null'}], jsonpath='null'}]}] 2018-02-15 20:43:57.960 ERROR 6 --- [nio-8080-exec-6] c.e.e.c.s.StatementResultServiceImpl : Unexpected exception invoking listener update method on listener class 'EventSinkListener' : HttpMessageNotWritableException : Could not write content: Infinite recursion (StackOverflowError) (through reference chain: com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]->com.vividsolutions.jts.geom.Point["envelope"]

It seems to be blocked in an infinite recursion, right?

The interesting thing is that if the event does not have an attribute of type geo:point, the rule with a nested attribute works correctly. It seems to be related to the parsing of an attribute of type geo:point only.

I am using Cepheus CEP v1.0.0 without Cepheus broker.

Any help?

Best Regards.

marcc-orange commented 6 years ago

I understand you are trying to serialize a Tracker type to a Text type. This was not anticipated, so you found an edge case.

Sadly, Cepheus CEP does not handle nesting of types (it would be nice to be able to just define the nested attribute is a Tracker (e.g { "name":"nested", "type":"Tracker" } in the out configuration).

For reference, others projects having the same problem with serializing a JTS Point geometry which seem related to your issue: https://github.com/bedatadriven/jackson-datatype-jts/issues/8 and https://github.com/bedatadriven/jackson-datatype-jts/issues/15.

What is unclear for me, is why you would like to serialize the whole Tracker event to Text when you already asked to match all its fields to the Alert type. The time and location from an Alert are taken from the Tracker, so why not add additional attributes if you need more info from the Tracker type in your Alert type.

If this is because you simplified the statement to demonstrate the problem compared to the original Geofencing example, maybe a solution in the mean time would be transpose each of the properties from the Tracker you want in the Alert like this:

{
    "service": "test",
    "servicePath": "/tracker",
    "host": "http://172.17.0.1:8080",
    "reset": true,
    "statements": [
        "INSERT INTO Alert SELECT *, 
                                  t.id as nestedAlertId,
                                  t.location as nestedAlertLocation,
                                  t.time as nestedAlertTime
         FROM Tracker t WHERE NOT polygon({point(0, 0), point(0,50), point(50,50), point(50, 0), point(0, 0)}).contains(t.location)"
    ],
    "in": [
        {
            "id": ".*",
            "type": "Tracker",
            "isPattern": true,
            "attributes": [
                {
                    "name": "time",
                    "type": "date"
                },
                {
                    "name": "location",
                    "type": "geo:point"
                }
            ],
            "providers": [
                {
                    "url": "http://172.17.0.1:1026",
                    "service": "test",
                    "servicePath": "/tracker"
                }
            ]
        }
    ],
    "out": [
        {
            "id": "Fence1",
            "type": "Alert",
            "attributes": [
                {
                    "name": "time",
                    "type": "date"
                },
                {
                    "name": "location",
                    "type": "geo:point"
                },
                {
                    "name": "inside",
                    "type": "boolean"
                },
                {
                    "name": "nestedAlertId",
                    "type": "string"
                },
                {
                    "name": "nestedAlertLocation",
                    "type": "geo:point"
                },
                {
                    "name": "nestedAlertTime",
                    "type": "date"
                }
            ],
            "brokers": [
                {
                    "url": "http://172.17.0.1:1026",
                    "serviceName": "test",
                    "servicePath": "/tracker",
                    "authToken": null
                }
            ]
        }
    ]
}
efviodo commented 6 years ago

The reason why I am trying to serialize the whole Tracker as "text" (could be even java.util.Map) is because Cepheus is part of a much more complex architecture of an IoT application where I have multiples types of context entities and each one generates Alerts. Then I am working on a integration component that takes each Alert and for example send it to a third party system (could be fire an Email, etc).

Since each context entity have a different schema (entity type) I want to define something like an "Envelope" entity type for all the alerts in order to get a common set of attributes, most of them for internal use. That's the reason why I am putting the whole Tracker info into a single attribute in my example. Just to clarify, I am not serializing Tracker as "text", in fact I am using type "java.util.Map". I put it as "text" in the issue just to make it simple.

In the meantime I can "flat" the whole context as you suggests at the cost of losing the "common" envelope.

Thank you and I hope you can incorporate this issue as a future bug fixes.

Best Regards.