And, I hope, it doesn&#39;t matter in which order the Events A with id x are matched with Events B with the same id.<br><br>The idea of my approach is to make the Events  A, B, C not directly visible to the rule ABC but through a &quot;filter&quot; fact, one per type (A, B. C) and per id. <br>
<br>Here is the abstract base class for the filter fact; Event is the base class for the three EventA/B/C (or use Object).<br><br>package event;<br>import java.util.*;<br>public abstract class EventList {<br>    private String id;<br>
    private List&lt;Event&gt; list;<br>    public EventList( int id ){<br>        <a href="http://this.id">this.id</a> = &quot;&quot; + id;<br>        list = new ArrayList&lt;Event&gt;();<br>    }<br>    public String getId(){<br>
        return id;<br>    }<br>    public int size(){<br>        return list.size();<br>    }    <br>    public void add( Event event ){<br>        list.add( event );<br>    }<br>    public void delFirst(){<br>        list.remove( 0 );<br>
    }<br>}<br><br>Here is the insertion:<br><br>        long t0 = System.currentTimeMillis();<br>        int limit = 10;<br>        EventListA[] aList = new EventListA[limit];<br>        EventListB[] bList = new EventListB[limit];<br>
        EventListC[] cList = new EventListC[limit];<br>        int count = 100;<br>        for( int i = 0; i &lt; limit; i++ ){<br>            aList[i] = new EventListA( i );<br>            bList[i] = new EventListB( i );<br>
            cList[i] = new EventListC( i );<br>            for( int j = 0; j &lt; count; j++ ){<br>                EventA eventA =  new EventA( i );<br>                aList[i].add( eventA );<br>                session.insert( eventA );<br>
                EventB eventB =  new EventB( i );<br>                bList[i].add( eventB );<br>                session.insert( eventB );<br>                EventC eventC =  new EventC( i );<br>                cList[i].add( eventC );<br>
                session.insert( eventC );<br>            }<br>            session.insert( aList[i] );<br>            session.insert( bList[i] );<br>            session.insert( cList[i] );<br>        }     <br>        session.fireAllRules();<br>
        long t1 = System.currentTimeMillis();<br>        System.out.println( &quot;id limit &quot; + limit + &quot;, execution of &quot; + count + &quot; identical triples: &quot; + (double)(t1-t0)/1000.0 );<br><br>Here&#39;s the rules:<br>
<br>rule ABC<br>when<br>  $a : EventListA( $aid: id, size &gt; 0 )<br>  $b : EventListB(id == $aid, size &gt; 0 )<br>  $c : EventListC(id == $aid, size &gt; 0 )<br>then<br>  $a.delFirst();<br>  update( $a );<br>  $b.delFirst();<br>
  update( $b );<br>  $c.delFirst();<br>  update( $c );<br>  // …(actions)<br>end<br><br>rule killEmtpyList<br>when<br>    $el: EventList( $id :  id, size == 0 )<br>then<br>    System.out.println( &quot;retracted &quot; + $el.getClass().getSimpleName() + $id );<br>
    retract( $el );<br>end<br><br>There are a couple of things to watch out for, and to refine.<br>* You may want to keep track of existing EventListX in maps, or use a couple of rules to create and add new EventX to their EventListX.<br>
* Perhaps another collection type is more efficient than ArrayList; depends on how many Xs with identical ids you expect.<br>* make sure to update after EventList.add and .delFirst, also when doing it in Java code. (My insert sequence inserts the completed EventList.)<br>
<br>An entirely different approach might be possible using temportal operators, provided the events have distinct timestamps:<br>   $a: EventA( $id : id, marked == false )<br>   not EventA( if == $id, this before $a, marked == false )<br>
   // same for B, C<br>but here you&#39;ll have to retract the &quot;winners&quot; or else mark them as matched.<br><br>HTH<br>-W<br><br><br><div class="gmail_quote">2010/11/15 Roess. Oliver <span dir="ltr">&lt;<a href="mailto:o.roess@seeburger.de">o.roess@seeburger.de</a>&gt;</span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">








<div link="blue" vlink="purple" lang="DE"><font size="1" color="#808080" face="Arial"></font><br>

<div>

<p class="MsoNormal"><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;" lang="EN-GB">Hello again!</span></font></p>

<p class="MsoNormal"><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;" lang="EN-GB"> </span></font></p>

<p class="MsoNormal"><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;" lang="EN-GB">Thanks for the heads up, Wolfgang. </span></font></p>

<p class="MsoNormal"><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;" lang="EN-GB"> </span></font></p>

<p class="MsoNormal"><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;" lang="EN-GB">Basically, what I try to create is some sort of batch
window, which is not really implemented into Drools Fusion if I remember correctly.</span></font></p>

<p class="MsoNormal"><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;" lang="EN-GB">It doesn’t HAVE to be A, B, C in that particular
order which I specified in my last post, but the rule shall only match each A,
each B, and each C once. So what would you recommend as a best practise to
build that rule? Or is my rule correct? Actually, I don’t like the fact,
that I have to complete the rule by retracting my events in the RHS of the rule.
I’d rather have a batch window specified in the LHS. Thanks in advance.</span></font></p>

<p class="MsoNormal"><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;" lang="EN-GB"> </span></font></p>

<p class="MsoNormal"><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;" lang="EN-GB">Best regards,</span></font></p>

<p class="MsoNormal"><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;" lang="EN-GB">Oliver</span></font></p><font color="#888888">

</font></div><div class="im">

<br><table style="border-collapse: collapse;" width="100%" border="0">
<tbody><tr>
                <td style="border-bottom-style: double; border-bottom-width: 3px;" width="272"> </td>
                <td style="border-bottom-style: double; border-bottom-width: 3px;" width="45"> </td>
                <td style="border-bottom-style: double; border-bottom-width: 3px;"> </td>
</tr></tbody></table>

<br><br>

<table style="border-collapse: collapse;" width="100%" border="0">
        <tbody><tr>
                <td width="272"><font size="1" color="#808080" face="Arial"><b>SEEBURGER AG</b></font></td>

                <td width="45"> </td>
                <td><font size="1" color="#808080" face="Arial">Vorstand/Seeburger Executive Board:</font></td>
        </tr>
        <tr>
                <td width="272"><font size="1" color="#808080" face="Arial">Sitz der Gesellschaft/Registered Office:</font></td>
                <td width="45"> </td>
                <td><font size="1" color="#808080" face="Arial">Bernd Seeburger, Axel Haas, Michael Kleeberg</font></td>
        </tr>
        <tr>
                <td width="272"><font size="1" color="#808080" face="Arial">Edisonstr. 1</font></td>
                <td width="45"> </td>
                <td><font size="1" color="#808080" face="Arial"></font></td>
        </tr>
        <tr>
                <td width="272"><font size="1" color="#808080" face="Arial">D-75015 Bretten</font></td>
                <td width="45"><font size="1" color="#808080" face="Arial"></font></td>
                <td><font size="1" color="#808080" face="Arial">Vorsitzender des Aufsichtsrats/Chairperson of the Seeburger Supervisory Board:</font></td>
        </tr>
        <tr>
                <td width="272"><font size="1" color="#808080" face="Arial">Tel.: 07252 / 96 - 0</font></td>
                <td width="45"><font size="1" color="#808080" face="Arial"></font></td>
                <td><font size="1" color="#808080" face="Arial">Dr. Franz Scherer</font></td>
        </tr>
        <tr>
                <td width="272"><font size="1" color="#808080" face="Arial">Fax: 07252 / 96 - 2222</font></td>
                <td width="45"><font size="1" color="#808080" face="Arial"></font></td>
                <td><font size="1" color="#808080" face="Arial"></font></td>
        </tr>
        <tr>
                <td width="272"><font size="1" color="#808080" face="Arial">Internet: <a href="http://www.seeburger.de" target="_blank">http://www.seeburger.de</a></font></td>
                <td width="45"><font size="1" color="#808080" face="Arial"></font></td>
                <td><font size="1" color="#808080" face="Arial">Registergericht/Commercial Register:</font></td>
        </tr>
        <tr>
                <td width="272"><font size="1" color="#808080" face="Arial">e-mail: <a href="mailto:info@seeburger.de" target="_blank">info@seeburger.de</a></font></td>
                <td width="45"><font size="1" color="#808080" face="Arial"></font></td>
                <td><font size="1" color="#808080" face="Arial">HRB 240708 Mannheim</font></td>
        </tr>
        
        
</tbody></table>

<p><font size="2" face="Arial"><br></font></p>
<p align="justify"><font size="1" color="#808080" face="Arial">Dieses E-Mail ist
nur für den Empfänger bestimmt, an den es gerichtet ist und kann vertrauliches
bzw. unter das Berufsgeheimnis fallendes Material enthalten. Jegliche darin
enthaltene Ansicht oder Meinungsäußerung ist die des Autors und stellt nicht
notwendigerweise die Ansicht oder Meinung der  dar. Sind Sie nicht der Empfänger, so haben Sie diese E-Mail irrtümlich erhalten und jegliche Verwendung, Veröffentlichung, Weiterleitung, Abschrift oder jeglicher Druck dieser E-Mail ist strengstens untersagt. Weder die  noch der Absender (Oliver Roess) übernehmen die Haftung für Viren; es obliegt Ihrer Verantwortung, die E-Mail und deren 
Anhänge (0) auf Viren zu prüfen.
<br><br>
<p align="justify"><font size="1" color="#808080" face="Arial">The present email addresses only the addressee which it targets and may contain confidential material that may be protected by the professional secret. The opinions reflected herein are not necessarily the one of the . If you are not the addressee, you have accidentally got this email and are not enabled to use, publish, forward, copy or print it in any way. Neither the , nor the sender (Oliver Roess) are liable for viruses, being your own responsibility to check this email and its attachments (0) for this purpose. 
<br><br><br></font></p></font></p></div></div>



<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><br>