Anton Arhipov
http://arhipov.blogspot.com
INTRODUCTION
Rule Engine
BRMS
Rule Engine
A business rules engine is a software system that executes one or more business rules in a runtime production environment. - Wikipedia
Advantages
• Declarative programming– Rule engines allow you to say "What to do" not "How to do it".
• Logic and data separation– Your data is in your domain objects, the logic is in the rules.
• Centralization of knowledge– By using rules, you create a repository of knowledge which is executable.
• Explanation facility– Rule systems effectively provide an "explanation facility" by being able to
log the decisions made by the rule engine along with why the decisions were made.
• Understandable rules– By creating object models and, optionally, Domain Specific Languages
that model your problem domain you can set yourself up to write rules that are very close to natural language.
When to use Rule Engine?
The general answer is: "when there is no satisfactory traditional programming approach to solve the problem"
• The problem is just too fiddle for traditional code. • The problem is beyond any obvious algorithm based solution. • The logic changes often • Domain experts are readily available, but are nontechnical.
If rules are a new technology for your project teams, the overhead in getting going must be factored in.
When NOT to use Rule Engine?
… in the excitement of working with rules engines, that people forget that a rules engine is only one
piece of a complex application or solution.
If you just need to bypass the release process, think twice before using the rule engine.
It works best if you can write
the rules in declarative manner
BRMS
A BRMS or Business Rule Management System is a software system used to manage the variety and complexity of decision logic (a.k.a business rules) that is used by operational systems within an
organization or enterprise. - Wikipedia
• Features:– A repository, allowing decision logic to be externalized
from core application code – Tools, allowing both technical developers and
business experts to define and manage decision logic – A runtime environment, allowing applications to
invoke decision logic managed within the BRMS and execute it using a business rule engine
Why do you need BRMS at all?
• Flexibility– Alter the system behavior in production
• Separation of concern– A good practice in software engineering, everything is
separated. Keep rules out of the application.
• Centralized rules repository – The dream of every IT organization.
• Business teams closer to implementation– The business analyst can view and play with rules
that effect business and hence get very close to the implementation.
Emmmm……
http://www.jboss.org/drools
http://blog.athico.com
irc.codehaus.org #drools
InfoWorld BOSSIE Awards 2008
Authoring
• Involves the creation of DRL or XML files for rules which are fed into a parser.
• Package builder also undertakes any code generation and compilation
• A package is self contained and deployable, in that it's a serialized object consisting of one or more rules.
The Rule
Runtime
• A RuleBase is a runtime component which consists of one or more packages.
• A RuleBase can instantiate one or more WorkingMemories.
The API
Deployment
DEMO
Questions yet?
Drools Flow
A workflow engine combining processes and rules
A workflow is a process that describes the order in which series of steps need to be executed,
using a flow chart.
Evaluating a set of rules in your process
The rules that need to be evaluated should be grouped in a ruleflow group (using the ruleflow-group rule attribute)
and a RuleSet node can be used to trigger the evaluation of these rules in your process.
Rules + Processes
A workflow engine combining processes and tools
• Why rules in processes?– Simplicity: Complex decisions are usually easier to specify
using a set of rules. – Agility: Rules and processes can have a separate life cycle. – Different scope: Rules can be reused accross processes or
outside processes. – Declarative: Focus on describing 'what' instead of 'how'. – Granularity: It is easy to write simple rules that handle specific
circumstances. Processes more suited to describe the overall control flow.
– Performance: No unnecessary passing, transformation or synchronization of data.
The API
DEMO
Question yet again??
Guided Editing
Guided Editing
Guided Editing
Decision Tables
QA
QA
What’s next?