Comments (2)
By default a rule is set to RuleChainActionType.CONTINUE_ON_FAILURE. That means that the rule chain will continue (i.e. the next rule in the chain will be evaluated) if the rule's "when" condition evaluates to false or if there is an error evaluating the rule. The rule is then, in effect, skipped. However, the rule chain will break if and only if the RuleState is set to BREAK (e.g. if the stop() method is used in the RuleBuilder), the rule's condition evaluates to true and there is no error when evaluating the rule. And if RuleState was not set to BREAK, the "when" condition evaluated to true and the rule's action(s) completed successfully then the rule chain continues and the next rule is evaluated. This was the only behavior of rules in RuleBook prior to v0.8 and it is now the default behavior.
Alternatively, if a rule is set to RuleChainActionType.STOP_ON_FAILURE then if the rule's condition evaluates to false or if an error is thrown while RuleState is BREAK, the rule chain is broken. However, if the rule's "when" condition evaluates to true without error, the rule chain continues. It's basically a way to break the rule chain on a failed rule.
What you saw in the code where STOP_ON_FAILURE sets the rule to RuleState.NEXT is a way of ensuring that the rule chain continues with STOP_ON_FAILURE set when the rule is successful (it's "when" condition evaluates to true). It was done like that so that it could work with the existing rule chain logic in the CoRRuleBook.
Does that make sense? I, personally didn't really like having two different possible behaviors. However, more than one person asked for a feature to break the rule chain on a failed rule. So, STOP_ON_FAILURE was an easy way to allow that to happen.
from rulebook.
Thank you for the explanation
from rulebook.
Related Issues (20)
- rule book runner incorrectly eats exceptions so buggy code is not caught. HOT 2
- Why withDefaultResult is mandatory? HOT 4
- How can i write dynamic rules to execute rather than writing in java program .like rules defined in JSON or Yaml? HOT 4
- Q: Rule as a singleton bean HOT 3
- Add the Supplier function to avoid the passage by reference for the default result HOT 2
- Should I fork? HOT 2
- using codegen to improving performance of rule execution HOT 1
- Rule name is dropping when build Rule withFactType. HOT 1
- How to write Unit Tests for a RuleBean? HOT 1
- Switch CI to GitHub Actions HOT 2
- Deprecated classes/methods and non-compiling examples in README.md HOT 1
- Auditor not set on rules when RuleBookBuilder.create(Class) is used HOT 2
- Futures/CompletionStage/Async HOT 2
- Fact checking before evaluating rules HOT 2
- Rulebook in Spring Boot - stop execution
- Project status HOT 2
- Lambdas stack error
- RuleBuilder doesn't create a Rule with action type RuleChainActionType.ERROR_ON_FAILURE HOT 2
- RuleBookRunner4PojoClasses does not run rules according to the order property
- Would need an update on how frequently this project is developed and actively supported HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rulebook.