Event History

Introduction

 

As seen in the simple example, our API is quite easy to use.

One of the big challenge is to know what is happening in the rule engine. The drools native API gives us all we need but you have to build all by yourself for each project you are doing.

The chtiJBUG drools APi comes with predefined listeners that when triggered will fulfill a history Container.

The insertObject, UpdateObject and retractObject take as a parameter the java beans you want to insert. It is stored in a Map therefor we are using the equals and hashcode to find the object to retract/update.

The fireAllRules and startProcess speak by themselves as well as the dispose method that you should call to properly dispose all java objects.

The interesting part of it is getHistoryContainer which gives the list of event happening. There are 3 types of event ; about facts, processes and rules

Fact Events

 

DeletedFactHistoryEventEach time there is a retracted object in the working memory (session) from java or from RHS (then), this event is added
InsertedFactHistoryEventEach time there is an inserted object in the working memory (session) from java from  RHS (then) of a rule, this event is added
UpdatedFactHistoryEvent

Each time there is an upaded object in the working memory (session) from java or from RHS (then), this event is added

Please not here that we record the old and new value of the updated object

 

 

Process Events

 

NodeInstanceAfterHistoryEventThis event is fired when leaving a node
NodeInstanceBeforeHistoryEventThis event is fired when entering a node
ProcessStartHistoryEventWhen a process is started
ProcessEndHistoryEventWhen a process is stoped

Our current implementation is enough when using BPMN2 process for ruleflow (see below). We shall improve it in the future DROOLS-7 - Getting issue details... STATUS

Rule Events

 

 

 

 

 

AfterRuleFlowActivatedHistoryEventEvent is fired when entering a ruleFlow group
AfterRuleFlowDeativatedHistoryEventEvent is fired when leaving a ruleflow group
AfterRuleFiredHistoryEventEvent fired after a rule was fired
BeforeRuleFiredHistoryEventEvent is fired before a rule is fired

 

Entity Model used for all history events

 

DroolsFactObjectEach time an object is inserted/retracted/updated a new DroolsFactObject is instanciated to keep the value it had. 
DroolsFactObjectAttribute

We are storing in a Key/value the value of an attribute where key is the name of the attrinute and value a string representation of the value. The Type attribute is "String, Long, long, etc..)

Note that in case the attribute is a class , the value contains the toString method of the inserted/deleted/updated java object