[rules-users] Drools Fusion Dropping Actions to Events?

Wolfgang Laun wolfgang.laun at gmail.com
Tue Apr 22 02:43:10 EDT 2014


This seems to be a race condition, the KIE session not being thread-safe:
if events are inserted in a tight loop, about 50% simply evaporate.
Using Thread.sleep(1) after each insert avoids all losses, but that's
hardly a
feasible workaround, since this doesn't guarantee that the thread running
the session has become active and "digested" the fact.

-W

On 22/04/2014, chandu_divi <chandu_divi at hotmail.com> wrote:
> I am using Drools Fusion 6.0.1.Final version, it looks like some (rather
> several) actions to the events are dropped. I am sending about 100K events
> and expecting an action to all the events, but only 5000 actions are
> performed, which means about 95K actopms are dropped.
>
> The same issue was posted in the thread
> http://drools.46999.n3.nabble.com/rules-users-Drools-Fusion-Dropping-Events-td4023843.html,
> but it is marked as resolved.
>
> The defect https://issues.jboss.org/browse/DROOLS-131 is also marked as
> fixed.
>
> But this issue seems to be appearing again.
>
> Here is my code.
>
> kmodule.xml
>
> <?xml version="1.0" encoding="UTF-8"?>
> <kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule">
>     <kbase name="eventDrop" packages="ed" eventProcessingMode="stream">
>         <ksession name="edSession"/>
>     </kbase>
> </kmodule>
>
> ed.drl
>
> package drools
>
> import foo.TemperatureEvent
>
> declare TemperatureEvent
> @role(event)
> end
>
> rule "RULE S1"
> when
>     $te:TemperatureEvent(measure <= 50) from entry-point entryone
> then
>     System.err.println("The temperature at location - "+$te.getLocation() +
> " is " + $te.getMeasure());
> end
>
> rule "RULE S2"
> when
>     $te:TemperatureEvent(measure > 50) from entry-point entryone
> then
>     System.err.println("The temperature at location - "+$te.getLocation() +
> " is " + $te.getMeasure());
> end
>
>
> TemperatureEvent.java
>
> package foo;
>
> public class TemperatureEvent {
>
>     int measure;
>     String location;
>     long timeStamp;
>
>     public TemperatureEvent(int measure, String location, long timeStamp) {
>         this.measure = measure;
>         this.location = location;
>         this.timeStamp = timeStamp;
>     }
>
>     public int getMeasure() {
>         return measure;
>     }
>
>     public void setMeasure(int measure) {
>         this.measure = measure;
>     }
>
>     public String getLocation() {
>         return location;
>     }
>
>     public void setLocation(String location) {
>         this.location = location;
>     }
>
>     public long getTimeStamp() {
>         return timeStamp;
>     }
>
>     public void setTimeStamp(long timeStamp) {
>         this.timeStamp = timeStamp;
>     }
> }
>
> App.java
>
> package foo;
>
> import java.io.FileOutputStream;
> import java.io.PrintStream;
> import java.util.Random;
>
> import org.kie.api.KieServices;
> import org.kie.api.runtime.KieContainer;
> import org.kie.api.runtime.KieSession;
> import org.kie.api.runtime.rule.EntryPoint;
>
> public class App {
>     public static void main(String[] args) throws Exception {
>         System.setErr(new PrintStream(new FileOutputStream("report.txt")));
>         // Start Drools.
>         KieServices ks = KieServices.Factory.get();
>         KieContainer kContainer = ks.getKieClasspathContainer();
>         final KieSession kSession = kContainer.newKieSession("edSession");
>         EntryPoint entryPoint1 = kSession.getEntryPoint("entryone");
>
>         new Thread() {
>             @Override
>             public void run() {
>                 kSession.fireUntilHalt();
>             }
>         }.start();
>
>         Random measure = new Random(System.currentTimeMillis());
>         Random location = new Random(System.currentTimeMillis() -
> 1000000L);
>         String locations[] = { "Bangalore", "Chennai", "Delhi", "Mumbai",
> "Kolkata" };
>         for (int i = 0; i < 10; ++i) {
>             for (int j = 0; j < 1000; ++j) {
>
>                 TemperatureEvent te = new TemperatureEvent(
>                         measure.nextInt(100),
> locations[location.nextInt(5)],
>                         System.currentTimeMillis());
>                 entryPoint1.insert(te);
> //                Thread.sleep(1);
>             }
>         }
>         Thread.sleep(100);
>         kSession.halt();
>         kSession.dispose();
>     }
> }
>
>
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Drools-Fusion-Dropping-Actions-to-Events-tp4029314.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>


More information about the rules-users mailing list