gerasalus [https://community.jboss.org/people/gerasalus] created the discussion

"Using drools in a web app is my approach correct"

To view the discussion, visit: https://community.jboss.org/message/761632#761632

--------------------------------------------------------------
Hi all,

some newbie questions. I'm wondering is my thinking and my architecture correct?

Preconditions:

1. We have a set of rules stored in DB.Rules will be reloaded from DB only once 
a day
2. We have a set of meta-facts. Retrieval of those facts is expensive, and they 
only get updated once a day, after midnight - current meta-facts are immutable 
for a day.
3. We have user facts - some user specific data which we should be using 
together with meta-facts and producing output for specific user.
4. Our SLA is 150 req/s. 

Typical flow would be something like: we have rules together with meta facts. 
Along comes user with his general facts and request specific facts. For this 
input we run rules and produce results - calculate some data. 
Basically a typical quote calculation, just we are not calculating quotes  :) 

Rules may change working memory  (cart explosion pattern)

So how would i make this work for multi user environment in a spring web apps? 
My ideas:

1. Create a custom Spring scope that will cache KnowledgeBase and invalidate it 
once it expires (at the beginning of new day)
2. Cache meta-facts (they are expensive to retrieve) for given time
3. For each user request (user comes in with its own facts) - create a new 
StatefulKnowledgeSession from existing KnowledgeBase byt inserting meta-facts 
and user specific facts and execute fireAllRules
4. Retrieve the result and dispose the StatefulKnowledgeSession()

As i unserstand, if my rules are modifying working memory, i cannot reuse 
StatefulKnowledgeSession for different users (as they bring their own facts).  
Is there a better approach ? By reading forums and mailing lists i have mixed 
data about StatefulKnowledgeSession creation. There are threads that state cpu 
spikes while creating sessions.

Maybe i should be considering pool of StatefulKnowledgeSession and 
inserting/retracing user facts while keeping meta-facts?

Thanks!
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/761632#761632]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]

_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to