(I am a bit new to working with Drools, so please excuse if this is a simple question).
I would like to use Drools for reactive execution of rules, this means we could consider the “facts” being inserted to be “event” instances. However, I want this to execute in a way that rules can be fired as soon as events are received. But, in the case that a rule may depend on several events, how can I configure the Working Memory, to remember previous events. Consider a very simple example:
Say I have the following rules:
- when (E1) do A1
- when (E2) do A2
- when (E1,E2) do A3
Then, if time progresses as follows, I want to following rules to be fired, example:
- t=1 , E1 happens => A1 fired
- t=2 , E2 happens => A2 fired + A3 fired
The problem I have is if I call ksession.fireAllRules()
after every insertion, the working memory will forget all previous events. What is the best way to achieve what I want?