j-easy / easy-rules

The simple, stupid rules engine for Java
https://github.com/j-easy/easy-rules/wiki
MIT License
4.93k stars 1.06k forks source link

Returning output of action from a rule #226

Closed kanteshkm closed 5 years ago

kanteshkm commented 5 years ago

Hi,

we are planning to use easy-rule in our project, we need to return value from a rule, below is the example:

SpELRule ageRule = new SpELRule() .name("Xpath rule") .description("XPath condition") .priority(1) .when(" #xpath1 == 'test' && #xpath2 == '2' && #xpath3 == '3' ") .then("#person.getValue(#xpath1)");

in the above rule, action will return a value [person.getValue()] and i need to return the value as response [it will be rest api, stateless]

is it possible to do return a value from matching rule?

thanks Kantesh

fmbenhassine commented 5 years ago

Please check Q2 in the FAQs section. Basically your rule should add a fact, then you can query the Facts object after rule execution to get the result.