Information Technology Reference
In-Depth Information
Drools Fusion functionalities
The Drools framework has a lot of different operators, functions, and special syntax that
could cover another topic by itself. They deal with comparing different objects within the
rule runtime memory. In this section, we'll concentrate to discuss the module more related
to temporal reasoning, which is called Drools Fusion .
Drools Fusion is not a separate dependency of Drools, but just a logical separation to keep
CEP-related documentation separate from the general body of knowledge of Drools Expert,
the main rule engine project. It comprises a way to declare facts as events, temporal operat-
ors to compare them, splitting of the rule runtime memory by stream origin, and the possib-
ility of using sliding windows to see the last events that match a specific condition. Let's
discuss each of these concepts in detail.
Event declarations
In the DRL language, you need to declare our events from a specific imported object type,
or you can even construct them directly. In the process-cep-examples project, you
will find a cepRules.drl file that defines one of these event types with the following
syntax:
declare ProcessEvent
@role(event)
processId: String
state: Integer
reqVariable: Object
end
Defining the @role annotation, we can tell the engine that a particular object type should
be treated as a fact (the default scenario) or an event (with time association). A Drools
event can have other attributes that will add special metadata to an object type. We'll enu-
merate them as follows:
@timestamp : This attribute receives one parameter, which should be the name of
an attribute in the object type. This attribute should contain a Date object, which
specifies the time at which the event happened. This is an optional annotation; be-
cause if it is not present, the moment the event is added to the rule memory will be
taken as the moment the event actually happened.
Search WWH ::




Custom Search