On 28/02/2012, gboro54 <gboro54(a)gmail.com> wrote:
We are currently authoring rules using Drools 5.3 and using jBPM 5.2
for
orchestration. The situation we have is as follows: Certain groups of rules
can execute on n number of messages in any order(i.e the order in which the
consequences occur does not matter). The problem comes in later in the
process when those same n messages need to have their consequences happen in
a certain order. Is there a good way to handle this? We have thought about
appending messages to a queue and just operating on one message at a time
however this seems slow.
"seems" seems to be not from experience. How big is n, how slow is slow?
A simple test will tell you all.
Nevertheless, there may be relatively slow and relatively fast
techniques for achieving firing in order. (I assume that ordering the
results is not an alternative to "firing in order".)
(a) Use dynamic salience, provided there is some integer ordinal as a
field of Message.
(b) Use a class Container { List<Message> msgs } as a fact, containing
all Messages in msgs. Insert Container as fact. Assuming your rules
run at salience 0 or higher:
rule nextMessage
salience -100
when
Container( $msgs: msgs, eval( $msgs.size() > 0 ) )
then
insert( msgs.remove( 0 ) );
end
rule noMoreMessages
salience -100
when
$cont: Container( $msgs: msgs, eval( $msgs.size() == 0 ) )
then
retract( $cont );
end
(This is a good example for the rule design pattern "Proxy Facts".)
-W
In addition when utilizing jBPM and drools what is
the best way to batch data in and out of the session. I understand starting
a new session is cheap but was hoping there may be a way to have jBPM insert
n records at a time and just continue to read from the db until no more
records are returned.
TIA!
--
View this message in context:
http://drools.46999.n3.nabble.com/Order-of-Execution-on-Messages-tp378401...
Sent from the Drools: User forum mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users