Re: [rules-users] Firiing explicit rules

2009-06-25 Thread Edson Tirelli
   Chris,

   The decision between A and B must be taken on the basis of: do you need
to join objects from the different streams together? If so, you need A. If
not, better go with B.

   Regarding threads, the engine works with a single thread, unless you
activate the KnowledgeBase partitioning option (check the Drools Fusion
documentation), in which case the engine spawns a pool of worker threads.
The threads are not assigned to specific streams. They are used as a pool
for processing of all required rules in the knowledge base.

   In any case, as long as you don't have multiple threads concurrently
inserting facts/events into a single entry-point, everything else is thread
safe.

   []s
   Edson


2009/6/24 Chris Richmond crichm...@referentia.com

  Hello,





 For performance reasons, assuming I am using STREAM mode, is it better to :



 A. create several streams in my rule file and inject objects into
 various streams depending on my needs



 or



 B. create a different session for each stream that I might have had in
 A. above?





 And if I do use option A, is my understanding correct that each stream will
 be processed on it’s own thread?



 And if so, I notice that I am able to update a common statistical object
 that I created within my rule file and update it from consequences on
 different streams.  If each stream is processed on it’s own thread, is
 updating of this in rule defined statistics object synchronized/thread safe?



 For example in my rule file I have the following “stats” object:



 # stats object

 declare ObjectStats

 id : String @key

 name: String

 lastReadingA : int

 lastReadingB : int



 end





 ….then I have the following two rules……



 rule update stats from objects A”

 lock-on-active

 when



 $stats : ObjectStats( $id : id)

 $a : ObjectTypeA(parentId == $id, $aValue : value) from entry-point
 “stream for objects of type a”



 then



 modify($stats) { lastReadingA = $aValue };





 end





 rule update stats from objects B”

 lock-on-active

 when



 $stats : ObjectStats( $id : id)

 $b : ObjectTypeB(parentId == $id, $bValue : value) from entry-point
 “stream for objects of type b”



 then



 modify($stats) { lastReadingB= $bValue };



 end





 This is working fine and the lock-on-active seems to be preventing me from
 getting the “cross product” problem, but is each of these streams processed
 independantly on their own thread?



 Thanks,



 Chris

 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
 Edson Tirelli
 JBoss Drools Core Development
 JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


RE: [rules-users] Firiing explicit rules

2009-06-25 Thread Chris Richmond
*Excellent* description of the system operation and overall and answer to my
question.   Thank you very much!

 

Chris

 

  _  

From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Edson Tirelli
Sent: Thursday, June 25, 2009 2:28 AM
To: Rules Users List
Subject: Re: [rules-users] Firiing explicit rules

 


   Chris, 

   The decision between A and B must be taken on the basis of: do you need
to join objects from the different streams together? If so, you need A. If
not, better go with B.

   Regarding threads, the engine works with a single thread, unless you
activate the KnowledgeBase partitioning option (check the Drools Fusion
documentation), in which case the engine spawns a pool of worker threads.
The threads are not assigned to specific streams. They are used as a pool
for processing of all required rules in the knowledge base.

   In any case, as long as you don't have multiple threads concurrently
inserting facts/events into a single entry-point, everything else is thread
safe.

   []s
   Edson



2009/6/24 Chris Richmond crichm...@referentia.com

Hello,

 

 

For performance reasons, assuming I am using STREAM mode, is it better to :

 

A. create several streams in my rule file and inject objects into
various streams depending on my needs

 

or

 

B. create a different session for each stream that I might have had in
A. above? 

 

 

And if I do use option A, is my understanding correct that each stream will
be processed on it's own thread?   

 

And if so, I notice that I am able to update a common statistical object
that I created within my rule file and update it from consequences on
different streams.  If each stream is processed on it's own thread, is
updating of this in rule defined statistics object synchronized/thread safe?

 

For example in my rule file I have the following stats object:

 

# stats object

declare ObjectStats

id : String @key

name: String

lastReadingA : int

lastReadingB : int

  

end

 

 

..then I have the following two rules..

 

rule update stats from objects A

lock-on-active

when

 

$stats : ObjectStats( $id : id) 

$a : ObjectTypeA(parentId == $id, $aValue : value) from entry-point
stream for objects of type a

 

then

 

modify($stats) { lastReadingA = $aValue };

 

 

end

 

 

rule update stats from objects B

lock-on-active

when

 

$stats : ObjectStats( $id : id) 

$b : ObjectTypeB(parentId == $id, $bValue : value) from entry-point
stream for objects of type b

 

then

 

modify($stats) { lastReadingB= $bValue };

 

end

 

 

This is working fine and the lock-on-active seems to be preventing me from
getting the cross product problem, but is each of these streams processed
independantly on their own thread?

 

Thanks,

 

Chris


___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users




-- 
 Edson Tirelli
 JBoss Drools Core Development
 JBoss by Red Hat @ www.jboss.com

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Firiing explicit rules

2009-06-24 Thread Chris Richmond
Hello,

 

 

For performance reasons, assuming I am using STREAM mode, is it better to :

 

A. create several streams in my rule file and inject objects into
various streams depending on my needs

 

or

 

B. create a different session for each stream that I might have had in
A. above? 

 

 

And if I do use option A, is my understanding correct that each stream will
be processed on it's own thread?   

 

And if so, I notice that I am able to update a common statistical object
that I created within my rule file and update it from consequences on
different streams.  If each stream is processed on it's own thread, is
updating of this in rule defined statistics object synchronized/thread safe?

 

For example in my rule file I have the following stats object:

 

# stats object

declare ObjectStats

id : String @key

name: String

lastReadingA : int

lastReadingB : int

  

end

 

 

..then I have the following two rules..

 

rule update stats from objects A

lock-on-active

when

 

$stats : ObjectStats( $id : id) 

$a : ObjectTypeA(parentId == $id, $aValue : value) from entry-point
stream for objects of type a

 

then

 

modify($stats) { lastReadingA = $aValue };

 

 

end

 

 

rule update stats from objects B

lock-on-active

when

 

$stats : ObjectStats( $id : id) 

$b : ObjectTypeB(parentId == $id, $bValue : value) from entry-point
stream for objects of type b

 

then

 

modify($stats) { lastReadingB= $bValue };

 

end

 

 

This is working fine and the lock-on-active seems to be preventing me from
getting the cross product problem, but is each of these streams processed
independantly on their own thread?

 

Thanks,

 

Chris

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users