0
votes

My question is:

In a Drools rule, there is a way to intercept the "success" event? For better explain... there's a way to call a listener when all the condition of a rule are true?

Note: I dont want to set a global object (on session) to manage this condition on the "then" clause of a rule.

I'm searching for a solution already implemented on Drools

Rule sample

when
    $p : Person(name == "James")  
then
      // implicit callback to the listener managed by drools
1

1 Answers

0
votes

In package org.kie.api.event.rule there are BeforeMatchFiredEvent and AfterMatchFiredEvent. Implement interface AgendaEventListener with methods void afterMatchFired(AfterMatchFiredEvent event) and/or void beforeMatchFired(BeforeMatchFiredEvent event).

You can learn about the rule that was fired and the participating facts by evaluating the data passed with the event parameter.