Skip to content

Instantly share code, notes, and snippets.

@bibryam
Last active October 16, 2015 14:00
Show Gist options
  • Select an option

  • Save bibryam/be8f8fb9a1dc31876541 to your computer and use it in GitHub Desktop.

Select an option

Save bibryam/be8f8fb9a1dc31876541 to your computer and use it in GitHub Desktop.
Complex Event Processing Rule to mark errors as critical
package org.kie.example.project1;
rule "Mark a request as critical when there are 5 or more in 10 seconds. There should be at most 1 critical per 10 minutes"
when
$requestQualifier: RequestQualifier(processed == false)
Number( intValue >=5 ) from accumulate($r: RequestQualifier( ) over window:time( 10s ),count( $r ) )
Number( intValue ==0 ) from accumulate($r: RequestQualifier( critical == true) over window:time(10m ),count( $r ) )
then
modify($requestQualifier) {
setProcessed(true),
setCritical(true);
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment