Esper EPL leftouter join forwarding to other stream

1k Views Asked by At

I have implemented ESPER for my application need of CEP. While using EPL I encountered a specific scenario which is as follows:

I have combined two events with left outer join to make sure each event from first can trigger the statement and only those from second stream which contains specific property can come along. I have created a view to store unique data based on some fields. My EPLs are

@Name ('StmtCombinedEvent')
Insert into CombinedEvent 
    Select S as T1,
    L as T2,
    From pattern[every S= bussinessObject.Type1].std:unique(S.Id) as S 
    left outer join 
    bussinessObject.Type2.std:unique(name) as L
    on S.name = L.name;


@Name ('StmtGroupingEvent')
Insert into Position
Select 
    G.T1 as T1
    G.T2 as T2
    From CombinedEvent.std:unique(T1.Id) as G;

I am using java.util.Map type for CombinedEvent dataType in configuration file

Now consider test scenario

  1. Two events of type T1 having different Id but having same name has been entered into system
  2. One event of type T2 is entered into system

Because of the view specification both event of type T1 resides into view and when event of type T2 enters into system, NewData parameter of type Event Bean contains both event of T1 (if I was using event listener in code), but as first EPL statement specifies it to insert into second statement it finds an error of mismatched type, as it was expecting event of type T2 for 'StmtGroupingEvent' but found Event Bean instead.

So I need to handle array type of data in EPL which would be cumbersome.

On the other hand if scenario is as follows:

  1. Only one event of type T1 is entered into system.
  2. One event of type T2 is entered into system.

This scenario doesn’t produce any error as Event Bean was successfully type casted to type T2.

So please suggest me any alternate way of doing this.

Thanks

1

There are 1 best solutions below

1
On

What does "it finds an error of mismatched type" mean? If there was an exception logged please post it and post a small test class alongside to reproduce. Also make sure you are using the latest version of Esper, if there is a bug it has likely been fixed in a newer version.

Also, use "from bussinessObject.Type1.std:unique(S.Id)" instead of pattern[every S= bussinessObject.Type1].std:unique(S.Id)", since the latter is a straight every it is the same.