complex-event-processingesper

Provide general query statement for all particular events


the following real use case, that already has been implemented by our company:

We've built application with rest api as wrapper around esper java api. The user can define it's map schema and query statement. Each event (instanceof MapEventBean) sent by user (as JSON) has one common parameter (thou with different values every time), which are to be added to map in background to the user map event as additional key-value pair.

Problem: in order to retrieve this additional parameter by UpdateListener, the user defined both schema and query statement are to be extended programmatically over this attribute.

E.g.:

User defined schema: create map schema Name as (...)

Prog. modified schema: create map schema Name as (additionalAttribute Map, ...)

User defined query stmt: select foo, bar from Name

Prog. modified query stmt: select additionalAttribute, foo, bar from Name

Question: approach does work, but is very error-prone or not too independent, as we'd like to have it.
So the question: Is any possibility to define common query stmt (e.g. select additionalAttribute on each event ...) or tell update listener to retrieve the particular attribute on each succeeded query, independently of whether it has been defined in user defined stmt or not.

Thanks in advance!

Update: I've already considered some possibilities such as NamedWindows, but the problem is, that this additional attributes are to belong to each particular event, - that is the attributes should be fetched from pattern by update listener simultaneously with the event self.


Solution

  • There is a statement object model API that you can use to modify the queries without doing string manipulation. The documentation link for the API is http://esper.espertech.com/release-8.0.0/reference-esper/html_single/index.html#apicompiler-soda