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