Does Drools Fusion have a "now" concept?

I am trying to write a rule that delays firing until at least 15 minutes have passed since the last shelling. However, the temporary operators in Drools Fusion only allow us to talk about two events in relation to each other, and not about one event relative to the current time.

I would like something like this:

rule "some rule" when not LastFiredEvent(this before[0m, 15m] NOW) … 

I resorted to writing a rule that fires every second and inserts a heartbeat event (also removes the previous beat), which I can use in other rules to serve as the current time.

I find it rather inelegant; Am I missing something or is Drools Fusion really not having something for this?

NB. I am not looking for a delay in firing according to the rules or rules, which can only work in multiples of 15 minutes; if nothing has happened in the past 17 minutes, the rule should immediately fire in response to a new event.

+6
rules drools drools-fusion
source share
1 answer

Although the NOW concept may seem simple at first, it is not, because it is ambiguous and depends on the different semantics that it can adopt based on the work environment. Drools Fusion has the concept of "NOW" when you start it in STREAM mode , but it is different from what you set above. The explanation here is a little longer, so let's focus on your problem.

Firstly, you say: “I am trying to write a rule that delays the shooting ...”, and then your opinion: “I am not looking for a deferral of shooting according to the rules ...”, so I am confused by what you need.

If you want to defer a rule, you can use the timer attribute:

 rule X timer( int: 15m ) ... 

If you want to run the rule in case the event happened or did not happen during the interval, you can use sliding windows. For example:.

 rule "Event did not happen in the last 15m" when not( SomeEvent() over time:window(15m) ) ... 

Hope this helps. And BTW, try posting your questions to the Drools mailing list as it will be easier for you to get an answer. I only saw your post because a friend asked me about it.

Cheers, Edson

+8
source share

All Articles