rule "example"
when
$evt1:EventObject(type=='a', $id:data['id'], $user:user) from entry-point internalstream
$evt2:EventObject(type=='a', data['id']==$id, user!=$user, $user2:user) from entry-point internalstream
not(EventObject(type=='b', user==$user, data['friendid']==$user2) from entry-point internalstream)
then
EventObject evt = new EventObject();
evt.setType('b');
evt.setUser($evt1.getUser());
evt.put('friendid', $evt2.getUser());
entryPoints['internalstream'].insert(evt);
end