Question

I need to handle a situation where I am notified when 2 different facts are received in my working memory within 30 seconds of each other. Then I want the system to remove the facts from the working memory after they are handled.

For example, say I want to be notified when the system sees a login from Bob and then he checks his email within 30 seconds.

I know that sounds banal, however, this is a proof-of-concept use-case and it's for a very high-level presentation.

I've tried this:

rule "Bob Login Rule" dialect "java"
when
    Login( username == "bob" ) over window:time(30s);
        UserAction (action == UserAction.CHECK_EMAIL) over window:time(30s)
then
    System.out.println("Bob logged in and checked his email");
end

Thanks in advance.

Was it helpful?

Solution

In this case you know that login < check-email but this may not always be so.

$login: Login( $uid: uid ) // a user logs in
$check: UserAction( uid == $uid, action == UserAction.CHECK_EMAIL, this after[0s,30s] $login)

Other operators are available that would not require a < b.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top