krl

Raising events in KRL without using explicit


I'm writing an app that raises events, similar to how Phil Windley's personal data manager application works. However, if I try to use any event domain but explicit, the events don't get propagated. The following rules work fine with explicit as the domain, but not with driverreg.

rule driver_info_submit {
    select when web pageview ".*"
    pre {
        driver_name = "Joe Driver";
        driver_phone = "111-555-1212";
        msg = <<
            Current driver info: #{ent:driver_name}, #{ent:driver_phone}
        >>;
    }
    notify("Started", msg);
    fired {
        raise explicit event new_driver_data with driver_name=driver_name and driver_phone=driver_phone;
    }
}

// Save driver name
rule save_driver_name {
    select when explicit new_driver_data
    pre {
        driver_name = event:param("driver_name") || ent:driver_name;
        driver_phone = event:param("driver_phone") || ent:driver_phone;
    }
    noop();
    always {
        set ent:driver_name driver_name;
        set ent:driver_phone driver_phone;
        raise explicit event driver_data_updated;
    }
}

rule driver_info_updated {
    select when explicit driver_data_updated
    {
        notify("Driver name", ent:driver_name);
        notify("Driver phone", ent:driver_phone);
    }
}

It doesn't seem to be a problem with whether the app is deployed, as I've tried it both ways. What am I missing?


Solution

  • Only certain domains are allowed as domains in the raise statement:

    This may be relaxed in the future.

    This is covered in the documents here: https://kynetxdoc.atlassian.net/wiki/display/docs/Raising+Explicit+Events+in+the+Postlude (note that this is a temporary home for the documentation)