Skip to content

Instantly share code, notes, and snippets.

@tsurdilo
Created July 1, 2011 14:53
Show Gist options
  • Save tsurdilo/1058706 to your computer and use it in GitHub Desktop.
Save tsurdilo/1058706 to your computer and use it in GitHub Desktop.
<br>Rule a1:
<br>Activation-group 'a'
<br>Salience 1000
<br>When
<br>SomeFact(value==10)
<br>Then
<br>DoSomething
<br>End
<br>
<br>Rule a2:
<br>Activation-group 'a'
<br>Salience 900
<br>When
<br>SomeFact(value &gt; 100)
<br>Then
<br>DoSomething
<br>End
<br>
<br>Rule a3:
<br>Activation-group 'a'
<br>Salience 800
<br>When
<br>SomeOtherFact(value != null)
<br>Then
<br>DoSomething
<br>End
<br>
<br>Rule a4:
<br>Activation-group 'a'
<br>When
<br>Then
<br>defaultAction
<br>End
<br>
<br>Rule b:
<br>Salience 2000
<br>When
<br>Then
<br>Insert(createSomeFact(10));
<br>End
<br>
<br>Rule c:
<br>Salience 1500
<br>When
<br>$sf : someFact(value == 10)
<br>Then
<br>$sf.setValue=200;
<br>Modify($sf);
<br>End
<br>
<br>Rule d:
<br>Salience 0
<br>When
<br>someFact(value &gt; 100)
<br>Then
<br>Insert(createSomeOtherFact(notNullData));
<br>End
<br>
<br>
<br>When executing fireAllRules(), the events that occur are:
<br>1) Rules b, and a4 fire because no facts exist yet
<br>2) Rule b causes rule a1 to fire
<br>3) Rule c fires next, causing rule a2 to fire
<br>4) Rule d fires next, causing rule a3 to fire
<br>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment