Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-2383

Heartbeat example seems broken

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Major Major
    • None
    • 7.6.0.Final
    • None
    • None
    • NEW
    • NEW

      To me it looks as if the common heartbeat example is broken:

      import foo.bar.Heartbeat
      
      rule "Sound the alarm"
      when
          $h: Heartbeat( ) from entry-point "MonitoringStream"
          not( Heartbeat( this != $h, this after[0s,10s] $h ) from entry-point "MonitoringStream" )
      then
         System.out.println("Sound the alarm");
      end
      

      When running the rule set with:

      public class Application {
          public static void main(final String[] args) {
              final KieServices ks = KieServices.Factory.get();
              final KieBaseConfiguration config = ks.newKieBaseConfiguration();
              config.setOption(EventProcessingOption.STREAM);
      
              final KieContainer kContainer = ks.getKieClasspathContainer();
              final KieBase kBase = kContainer.getKieBase("rules");
      
              final KieSession kSession = kBase.newKieSession();
      
              kSession.getEntryPoint("MonitoringStream").insert(new Heartbeat());
              kSession.fireUntilHalt();
          }
      }
      

      Results in:

      11:55:55.092 [main] DEBUG org.drools.compiler.kie.builder.impl.ClasspathKieProject - Found and used pom.properties /home/jreimann/Development/iot-kura-develop-oxygen/ws/drools-test-1/target/classes/META-INF/maven/de.dentrassi.test/drools-test-1/pom.properties
      11:55:55.095 [main] DEBUG org.drools.compiler.kie.builder.impl.ClasspathKieProject - Discovered classpath module de.dentrassi.test:drools-test-1:0.0.1-SNAPSHOT
      11:55:55.098 [main] INFO org.drools.compiler.kie.builder.impl.KieRepositoryImpl - KieModule was added: FileKieModule[releaseId=de.dentrassi.test:drools-test-1:0.0.1-SNAPSHOT,file=/home/jreimann/Development/iot-kura-develop-oxygen/ws/drools-test-1/target/classes]
      11:55:55.820 [main] DEBUG org.drools.core.common.DefaultAgenda - State was INACTIVE is now FIRING_UNTIL_HALT
      Sound the alarm
      11:55:55.850 [main] DEBUG org.drools.core.common.DefaultAgenda - State was FIRING_UNTIL_HALT is now INACTIVE_ON_FIRING_UNTIL_HALT
      

      Which looks to me as if the alarm gets activated right away instead of 10 seconds after.

              mfusco@redhat.com Mario Fusco
              jreimann-2 Jens Reimann
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: