-
Bug
-
Resolution: Done
-
Major
-
None
-
7.74.1.Final
-
None
-
2024 Week 07-09 (from Feb 12)
-
NEW
-
NEW
-
---
-
---
The DRL like this:
package org.example.drools; import org.example.drools.DispatchEvent; global java.util.List results; rule "Rule1" when $e : DispatchEvent($id : id) from entry-point "events" then results.add("received event: " + $id); System.out.println("received event: " + $id); end
And fire the rule in JavaCode
EntryPoint events = session.getEntryPoint("events"); Executors.newSingleThreadExecutor() .submit(() -> { try { System.out.println("fire until halt..."); session.fireUntilHalt(); } catch (Throwable e) { e.printStackTrace(System.err); } }); sleep(1000); System.out.println("insert event aaa"); events.insert(new DispatchEvent("aaa")); //sleep(100); System.out.println("insert event bbb"); events.insert(new DispatchEvent("bbb")); //sleep(100); System.out.println("halt..."); session.halt(); sleep(1000);
Output:
fire until halt... insert event aaa insert event bbb halt... received event: aaa
The event "bbb" is lost.
Add calling sleep() (whether added after inserting "aaa" or "bbb", I don't know why.), it could work fine.
However, in real-production or in concurrent cases, it's difficult to determine how long the sleep duration should be.