Hi,
First time posting in the mailing list, so I apologise if I make any silly
mistakes.
I have two classes MachineOnline and MachineOffline, which denote when a
machine is online and offline respectively
public class MachineOnline {
int machineId
}
These are declared in the drl file as events, so Drools Fusion
automatically generates the timestamp for me (I am running in STREAM mode,
so i get real time updates on the machine status)
declare MachineOnline
@role(event)
end
I then have a rule to generate the duration when the machine is online, but
I cannot seem to extract the timestamp that drools automatically inserts. A
thread a few years ago suggested using .startTimestamp, but Drools does not
seem to recognise it as a field. I believe that needs an EventFactHandle,
but I'm not sure how to retrieve that inside the drl file.
rule "Find duration machine is online"
when $message1 : MachineOnline()
$message2: MachineOffline(machineId == $message1.machineId &&
this after $message1) // + more rules to handle edge cases
then
//processing
duration = $message2.startTimestamp - $message1.startTimestamp ?
end
The eventual aim is to allow for a query that allows me to find how long
the machine is online for during a specified time interval, so if there is
a way to do this without needing to retrieve the actual timestamp of each
event, that will be great too. Or would it be better to manually define a
timeStamp field for each event? I've been using the default one as that
together with the pseudo allows for easy unit testing.
Thanks a lot!
Regards
Jing