[rules-users] Streaming mode

Richard Calmbach rcalmbac at gmail.com
Sat Mar 3 23:36:08 EST 2012


2012/3/2 Matteo Cusmai <cusmaimatteo at gmail.com>

> i see that there are some other threads that insert new event and some
> others retract them.
> How is the thread model?
>

Contrary to claims made on this mailing list, StatefulKnowledgeSession is
not thread-safe (this may be due to bugs, but bottomline is: it's not
thread-safe). In order to avoid errors due to multi-threading, don't use
fireUntilHalt(), instead synchronize on the session and only call insert()
and fireAllRules() while synchronized on the session:

    synchronized (session) {
        entryPoint.insert(event);
        session.fireAllRules();
    }

-Richard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20120303/d50549ea/attachment.html 


More information about the rules-users mailing list