Hello,
I'm a new user of Drools and have experimented with the basics. I am
interested in processing events and have had success when defining rules
of the type:
rule "example"
when
Event1(..) from entry-point Event1Store
Event2(..) from entry-point Event2Store
then
System.out.println("Fired!");
end
Where events of type Event1 and Event2 are continually injected into
entry-points within the working memory.
The events I have in mind are formed from data that sit in data stores
that are expensive to access and I would like to explore strategies for
minimising access to these. In the above example, I assume that if
Drools does not match the pattern Event1(..) then it will not try and
match the pattern Event2(..), in which case it would not be necessary to
construct facts/events which may match the Event2(..) pattern.
I understand that the 'from' statement can be used to evaluate facts
that are not in working memory, on this basis I have defined proxy
objects that are inserted into working memory which are then evaluated
for the actual data from the database on demand:
1 rule "example"
2 when
3 $event1Provider : Event1Provider()
4 Event1(..) from $event1Provider.evaluate()
5 $event2Provider : Event2Provider()
6 Event2(..) from $event2Provider.evaluate()
7 then
8 System.out.println("Fired!");
9 end
On the basis that if line 4 fails to match, then line 5 and 6 will not
get evaluated therefore avoiding accessing the database describing the
Event2 fact/event. I think that this works - but only once, since it
looks like the system is treating these as facts, that don't expire,
rather than events. Is it the case that the 'from' statement cannot be
used for events in this way? If not, what approach should be taken to
addressing the problem I am trying to solve?
Any direction would be much appreciated.
James