[rules-users] Streaming mode
Mark Proctor
mproctor at codehaus.org
Sun Mar 4 03:43:52 EST 2012
If you have found an area where it is not thread safe, then please let
us know so we can fix it. The example you have is redundant (possibly
out of date), those areas are covered:
fireAllRules and fireUntilHalt both have an atomic boolean, to ensure
they can never be called more than once at the same time.
if ( this.firing.compareAndSet( false, true ) ) {
.....
}
Each method that undertakes a working memory operation; such as insert,
update, retract creates a read lock on the KnowledgeBase and also a
read/write lock on the session.
FactHandle insert(final Object object,
final boolean dynamic,
boolean logical,
final Rule rule,
final Activation activation) throws
FactException {
....
....
try {
this.ruleBase.readLock();
this.lock.lock();
.....
} finally {
this.lock.unlock();
this.ruleBase.readUnlock();
}
On 04/03/2012 04:36, Richard Calmbach wrote:
> 2012/3/2 Matteo Cusmai <cusmaimatteo at gmail.com
> <mailto: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
>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20120304/39c9040b/attachment.html
More information about the rules-users
mailing list