[rules-users] Batch processing of facts in Drools?

Enda J Diggins ejdiggins at gmail.com
Thu Mar 11 07:26:03 EST 2010


Hi Ryan,

How many rule files / flows are we talking about? Is there one "Master" (for
want of a better word) flow that controls the entire adjudication process?
If so could you have a first step that inserts one fact from a list, moves
on to the adjudication process, then loops back until there are no facts
left? Should be easy to do with a few decision nodes and maybe an activation
group:

[Step 1: Insert fact]
[Step 2: Adjudicate]
{Decision: have more facts?} - Yes -> Step 1
- No -> Step 3
[Step 3: Finish]

If you just have one rule file, maybe you could have a rule with a salience
lower than any other that inserts one fact.

rule getStarted
salience -1000
 when
  $stack : StackOfStarterFacts(this.size != 0)
 then
  insert($stack.pop());
end

If you assume every other rule depends on these starter facts to execute and
have a salience higher than -1000, this could work.
The getStarted rule should fire once at the beginning then again when all
other adjudication has finished, restarting the process.
This might be harder to maintain.

Hope it gives you some ideas!

Enda

2010/3/11 Ryan Fitzgerald <ryan.fitzgerald at ericsson.com>

>  Hi,
>
> In our application, we want to process a large amount of facts. However, to
> avoid an overload on memory and drools, we would like to process the facts
> in batches.
>
> Our rules are setup so that we only insert a small number of initial or
> "root" facts, and then these facts trigger rules to fire that cause many
> other facts to be inserted, themselves triggering other rules.
>
> One way of batching this would be for the application to only insert the
> root facts into memory one by one and not inserting the next root fact until
> the previous one (and the batch of facts associated with it) have been
> processed and subsequently revoked.
>
> However, instead of the batching being controlled by the application, I
> would like to use a rule to do this i.e. insert all the root facts into
> memory and then call fireAllRules and have them processed one at a time.
>
> Does anyone have an idea how I can write a rule that causes a set of facts
> to trigger their rules, one fact at a time?
>
> Thanks.
>
>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>


-- 
Enda J Diggins
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20100311/32487fd0/attachment.html 


More information about the rules-users mailing list