Hello,<div><br></div><div>With the help from the community I managed to get my first rule working, and I&#39;m trying to write my second rule on my own but it just doesn&#39;t seem to work correctly.</div><div>Here is the scenario, what I want is to identify a pattern that there&#39;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&#39;t seem to work correctly. </div><div>I used a timer to fire this rule every 10 seconds because I don&#39;t think the rule would run automatically if I don&#39;t add that. (not too sure though)</div>
<div><br></div><div><div><div>rule &quot;no B in 2 minutes&quot;</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 &quot;Event stream&quot;</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>$p : PatternConsumer ( name == &#39;no B&#39; &amp;&amp; index == $index )</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>not ( EventB( index == $index &amp;&amp; this after[0ms,2m] $p) over window:time(2m) from entry-point &quot;Event stream&quot; )</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( &quot;no B&quot;, $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(&quot;no B in 2 minutes &quot; + $index);</div><div>
end</div></div></div><div><br></div><div>Best Regards,</div><div>Kevin Zhao</div>