Hanging/Long waiting threads in BRMS/BPM Suite 6 when using rule engine in active mode
Issue
When following Drools community document page 7.5.2. Active Mode to run rules engine in the below way
KieSessionConfiguration config = KieServices.Factory.get().newKieSessionConfiguration();
config.setOption( ClockTypeOption.get("realtime") );
KieSession session = kbase.newKieSession( conf, null );
new Thread( new Runnable() {
@Override
public void run() {
session.fireUntilHalt();
}
} ).start();
Hanging or long time waiting threads can be observed (application becomes unresponsive) when calling StatefulKnowledgeSessionImpl.insert(fact) method in another thread.
Checking the thread dumps, there is a HashMap (which is thread unsafe) being used by 2 (or more) different threads like below:
"Thread-83" prio=10 tid=0x00007f1dcc900000 nid=0x659c runnable [0x00007f1d798d7000]
java.lang.Thread.State: RUNNABLE
at java.util.HashMap.put(HashMap.java:498)
at org.drools.core.time.impl.TrackableTimeJobFactoryManager.addTimerJobInstance(TrackableTimeJobFactoryManager.java:65)
at org.drools.core.time.impl.JDKTimerService.internalSchedule(JDKTimerService.java:126)
at org.drools.core.time.impl.JDKTimerService.scheduleJob(JDKTimerService.java:99)
... ...
at org.drools.core.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:1541)
at org.drools.core.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:1487)
"Thread--fireUntilHalt" prio=10 tid=0x00007f1dcc840800 nid=0x1d7b runnable [0x00007f1d7adec000]
java.lang.Thread.State: RUNNABLE
at java.util.HashMap.removeEntryForKey(HashMap.java:694)
at java.util.HashMap.remove(HashMap.java:660)
at org.drools.core.time.EnqueuedSelfRemovalJobContext$1.execute(EnqueuedSelfRemovalJobContext.java:35)
... ...
at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireUntilHalt(StatefulKnowledgeSessionImpl.java:1404)
at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireUntilHalt(StatefulKnowledgeSessionImpl.java:1383)
Environment
- Red Hat JBoss BRMS
- Red Hat JBoss BPM Suite
- 6.x
- 7.0
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
