TnX Mike 4 the quick response.
 
I'm afraid that u r right regarding the through-put ;-(
Using the "synchronized" method will probably solve my problem but will damage the solution.
 
If u have any other thoughts on the matter i would love 2 hear them.
 
Regards
Dotan






Subject: RE: [rules-dev] Multi threading usage best practice
Date: Mon, 14 Jul 2008 14:24:02 +0100
From: manstis1@ford.com
To: rules-dev@lists.jboss.org


Hi,
 
Would synchronising on working memory effectively serialise the effects of fireAllRules()?
...
synchronised(wm) {
    wm.fireAllRules();
}
...
I don't know whether this would kill your through-put either.
 
Cheers,
 
Mike


From: rules-dev-bounces@lists.jboss.org [mailto:rules-dev-bounces@lists.jboss.org] On Behalf Of 9Lives 9Lives
Sent: 14 July 2008 13:41
To: rules-dev@lists.jboss.org
Subject: [rules-dev] Multi threading usage best practice

Hello
 
I'm using Drools 4.0.7 inside a mail relay application 2 determine the operations that need 2 b executed on each passing message.
To do this i'm using the following scenario:
  1. I have a ruleBase.newStatefulSession().
  2. I have a fixed set of facts.
  3. I have a fixed set of rules.
  4. Each mailer (a thread that is handling a single message) is inserting the message to the working memory, calls the "fireAllRules" method and retracts the message.
  5. Rules that r executed change custom attributes in the message.
Problem:
I noticed that sometimes a rule can b executed on the same message more then once.
 
Assumption:
My guess is that because i'm working is a multi threading environment but using a stateful session, what happens is:
  1. Thread A is inserting Message A.
  2. Thread B is inserting Message B
  3. Thread A is calling fireAllRules
  4. Rule X is executed on messages A + B.
  5. Thread B is calling fireAllRules
  6. Rule X is executed on messages A + B
  7. Thread A is retracting Message A
  8. Thread B is retracting message B
Question:
My goal is 2 make sure a rule is executed only once on a single message.
Any ideas on how 2 avoid the situation described above?
 
TnX
Dotan
 
 


Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! Try it!


Discover the new Windows Vista Learn more!