Hello,<div><br></div><div>With the help from the community I managed to get my first rule working, and I'm trying to write my second rule on my own but it just doesn't seem to work correctly.</div><div>Here is the scenario, what I want is to identify a pattern that there's no EventB coming in within 2 minutes with a particular index value. </div>
<div><br></div><div>For example, EventB would have a property named index and assume the value of index would be either 0 or 1. </div><div>Before firing the rules, I would manually insert facts of possibleIndex with value 0 and 1 into the workingMemory.</div>
<div><br></div><div>Within 2 minutes, if there only comes one EventB with index valued 0 then the system should report no EventB coming in with index value 1 in last 2 minutes.</div><div>Vice versa, in the case of only coming one EventB with index valued 1 then the system should report no EventB coming in with index value 0 in last 2 minutes.</div>
<div>If within 2 minutes, there comes 2 EventB with both value 0 and 1 then nothing should report.</div><div><br></div><div>Here is what I wrote, but it doesn't seem to work correctly. </div><div>I used a timer to fire this rule every 10 seconds because I don't think the rule would run automatically if I don't add that. (not too sure though)</div>
<div><br></div><div><div><div>rule "no B in 2 minutes"</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>timer (0 10s)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span></div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>when</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>possibleIndex( $index : index ) from entry-point "Event stream"</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>$p : PatternConsumer ( name == 'no B' && index == $index )</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>not ( EventB( index == $index && this after[0ms,2m] $p) over window:time(2m) from entry-point "Event stream" )</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>then</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>PatternConsumer pc = new PatternConsumer( "no B", $index );</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>insert(pc);</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>System.out.println("no B in 2 minutes " + $index);</div><div>
end</div></div></div><div><br></div><div>Best Regards,</div><div>Kevin Zhao</div>