0

I am developing an application with Esper where I need to create a complex event from fundamental events and enrich the event with information that is stored in an external model. As I am new to Esper I was wondering if there is a better (in terms of performance) approach than writing a pattern, attach a listener and then build and enrich the complex event within the listener and send the event via sendEvent-function. Maybe it is even possible to use the insert into EVENTNAME approach,.. but I am not sure how to du the enriching ...?

As an example: Several sensors are attached to a person and fire events with position etc. These events are to be composed to one PersonEvent and enriched by the name, etc. Also a bit unelegant seems to me that I need to create a pattern for each person.

I am looking forward to your advise and ideas very much. Tried to find something on this in the internet, but most of the sources are concerned with more simple approaches.

Cheers,

Chaoz

Chaoz77
  • 37
  • 7

1 Answers1

0

I would pull the external data only when its needed. So only when the useful situation or pattern completes. You can do this in listener code or you can add expressions to the select clause or you could use "insert into" to populate another stream. If you populate another stream then you can use EPL to join that output stream to external resources such as relational database. You could use extension APIs to plug in your own expressions.

user650839
  • 2,594
  • 1
  • 13
  • 9
  • I agree that enrichment should be only done when pattern completes because only then the enrichment is needed due to the existence of a new complex event. Could you go more into details about the expressions n the select clause approach? How would you populate this into a stream? Something like: insert into PersonEventselect id as pID, "+mgr.getName()+" as name from pattern ["+pattern+"]" Is creating a pattern for every person's nodes a good approach? – Chaoz77 Jun 04 '14 at 19:51
  • The latter insert into approach would however not wait for the pattern to be triggered i think... – Chaoz77 Jun 04 '14 at 20:42
  • you could do:insert into OutStream select * from pattern[a=A ... b=B..] , then "select *, a.xyz from OutStream..." – user650839 Jun 04 '14 at 20:49
  • Is it then a design flaw to have data external data stored in a complex event? I still can't see how I could enrich the data with e.g. a looked up name with your approach without using java code in the listener. or would you follow my idea with the mgr.getName() approach within the second select? – Chaoz77 Jun 04 '14 at 21:02
  • Sorry again, for the additional post. I was just thinking about your approach and it might work and be quite elegant, but how would you use information that has been retrieved within the first query in the second one to enrich the eventbean? talking here about the name thing.. mgr.getName(pID) where pID would be somehow retrieved from the first query. is this, what you meant to say? Also it is unclear if whether the complex event is triggered by 2 or 4 events. – Chaoz77 Jun 04 '14 at 21:10
  • If the external data stays cached then there is no need to look it up again. If it gets released from memory it would need to be looked up again. – user650839 Jun 05 '14 at 14:39