[rules-users] Best approach for handling parallel requests for a stateful rules session

Greg Barton greg_barton at yahoo.com
Tue Mar 8 13:12:25 EST 2011


Take a look at the org.drools.StatefulSession.async*() methods.  I've used them in a multithreaded context before.  

--- On Tue, 3/8/11, jkrupka <jkrupka at gmail.com> wrote:

> From: jkrupka <jkrupka at gmail.com>
> Subject: [rules-users] Best approach for handling parallel requests for a stateful rules session
> To: rules-users at lists.jboss.org
> Date: Tuesday, March 8, 2011, 11:10 AM
> We've been over multiple ways of
> handling multiple parallel requests for a
> stateful rules session and I want to make sure the approach
> we have settled
> on makes sense.
> 
> We will be getting multiple requests at a time to run some
> score calculation
> rules for various products.  In the past we used
> stateless rules sessions to
> do this and it worked fine.  In the newer version of
> our application we are
> using significantly more data to do our calculation and are
> pretty sure
> stateful is the way to go.  That being said, can we
> use the same session in
> multiple threads?  Based on our understanding, a
> session isn't inherently
> thread safe, so we are thinking we will need to do one of
> two things:
> 
> 1. Synchronize all updates to facts and the calling of
> fireAllRules so that
> only one thread is doing this at a time.  Is this the
> best (or only safe)
> approach in this situation?  Since all fact updates
> and rules running in
> done in one thread, when is throughput a concern (obviously
> depends on
> hardware, # of rules, # of facts, etc)?
> 2. Ensure that only one thread updates the facts related to
> a given product
> at a time.  Multiple threads could still call
> fireAllRules at the same time,
> but after the rules finish, the calling class would grab
> the facts that
> would have been updated for just the product that it's
> interested in.  That
> way, it doesn't matter if the rules were technically
> matched in a different
> thread, as long as I'm grabbing just the data I'm
> interested in.   Is this a
> safe approach?  Does it end up offering more
> throughput capability than
> approach #1?
> 
> Josh
> 
> --
> View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Best-approach-for-handling-parallel-requests-for-a-stateful-rules-session-tp2651617p2651617.html
> Sent from the Drools - User 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