Let’s put ourserlves in the next scenario, we are owners of a franchise and we have two stores. These stores sell different kind of products. We are planning to give a monetary award to the store that exceeds the Sales Record of u$s 1000. So, How shall we do it???…. You are right, with Drools Fusion.
Our project will be implemented using Maven and in the pom.xml we should add the next Dependencies:
The Sales will be our EVENTS, we don`t know when they are going to happen but they certainly will. Considering this, the next thing to do is create our Sale Class (POJO) and declare it in our DRL File as an Event.
Once we have declared the Sale as an Event, we are able to write the Rules Set:

Finally let’s create our Drools Session and insert the events in the suitable entry-point of the WorkingMemory(Session).
After running the java application, you should see that the StoreOne is the winner.
In Conclusion:
-An Event is a Fact with a TimeStamp.
-EntryPoints allow us to classify the Events, so we can only get matching events from an specific entry-point.
-Entry points are declared implicitly in Drools by directly making use of them in rules.





I am really enjoying these posts on drools. I have found it difficult to find conscise well defined examples as you have done. Keep them coming. Also, could you post source code, or at least post the code in the post not in images, that makes it easier to get your examples running. But great work!
Excelent Blog.. I was finding examples about drools fusion and CEP.
Do you have any example using CEP and TimeStamp?? for example.. IF amount of sales on the last 5 days is greater than 10000 then alert..
I need manage time intervals on drools..
ty so much..
Robson
Excelent Blog.. I was finding examples about drools fusion and CEP.
Do you have any example using CEP and TimeStamp?? for example.. IF amount of sales on the last 5 days is greater than 10000 then alert..
I need manage time intervals on drools..
ty so much..
Robson
Thanks for the example. I created a Maven project. Placed the Sale.java and Example1.java under src/main/java and placed the sales.drl under src/main/resources. When I executed Example1.java I get a runtime exception. Any feedback on what is going on.
Exception in thread “main” java.lang.IllegalAccessError: tried to access class org.techflow.drools.example.Sale from class org.drools.base.org.techflow.drools.example.Sale7388808$getAmount
at org.drools.base.org.techflow.drools.example.Sale7388808$getAmount.getLongValue(Unknown Source)
at org.drools.base.ClassFieldReader.getLongValue(ClassFieldReader.java:171)
at org.drools.rule.Declaration.getLongValue(Declaration.java:279)
at org.techflow.drools.example.Rule_StoreOne___has_passed_its_Sales_Record_0AccumulateExpression0Invoker.evaluate(Rule_StoreOne___has_passed_its_Sales_Record_0AccumulateExpression0Invoker.java:19)
at org.drools.base.accumulators.JavaAccumulatorFunctionExecutor.accumulate(JavaAccumulatorFunctionExecutor.java:109)
at org.drools.rule.Accumulate.accumulate(Accumulate.java:164)
at org.drools.reteoo.AccumulateNode.addMatch(AccumulateNode.java:777)
at org.drools.reteoo.AccumulateNode.assertObject(AccumulateNode.java:262)
at org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:59)
at org.drools.reteoo.PropagationQueuingNode$AssertAction.execute(PropagationQueuingNode.java:347)
at org.drools.reteoo.PropagationQueuingNode.propagateActions(PropagationQueuingNode.java:229)
at org.drools.reteoo.PropagationQueuingNode$PropagateAction.execute(PropagationQueuingNode.java:443)
at org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:1471)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:182)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:145)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:96)
at org.techflow.drools.example.Example1.insertEvent(Example1.java:56)
at org.techflow.drools.example.Example1.main(Example1.java:47)
I dun understand why u need to use drools fusion for this sample?? Can’t you just use Drools Expert to get the same result?
Hi,
The idea is to see the difference between the concept of fact and event. An event can be consider as a fact with a timestamp. The idea of fusion is to work with rules that work with events, And thats why
there are operators such as afte[], before[]. If we use facts, it would be to complex to see correlation between them.
is FireAllRules a mandatory in case the processing option is mandatory ? For me this seems counter intuitive as when its a stream, does’nt the events should get processes as and when it occurs ? In case of a stream of events coming in, how do one decide when to fire the rules ?
is FireAllRules a mandatory in case the processing option is STREAM ? For me this seems counter intuitive as when its a stream, does’nt the events should get processes as and when it occurs ? In case of a stream of events coming in, how do one decide when to fire the rules ?