Leading companies are tackling the complexity of their application and IT environments with service-oriented architecture (SOA), which facilitates the development of enterprise applications as modular business services that can be easily integrated and reused, thereby creating a truly flexible, adaptable IT infrastructure. Business process management (BPM) solutions such as those based on Business Process Execution Language (BPEL) enable services to be orchestrated into business processes. Processes built using a BPM solution can be reused, changed easily in response to business requirements, and enable real-time process visibility.
The promise of SOA is simplified integration, increased reuse, greater agility, and reduced risk. SOA and BPM deliver increased agility through three key enablers:
1. Reducing the time that it takes to automate business processes by reducing the gap between model and implementation, and enabling easier reuse of existing assets that can be exposed as services and then reused
2. Enabling business processes already implemented as orchestration of services to be changed rapidly
3. Freeing up funds for projects that enhance business agility by giving IT the ability to reduce spending on maintenance - after all, a capability that is implemented once, as a service, provides a single point of change and is easier to maintain when compared to the scenario in which it's embedded multiple times in different applications.
Agility is one of the biggest promises of BPM: the ability to make rapid changes to processes in step with the changes that occur inside of your business. Such changes are not always changes to the process. Often they are changes to the rules that drive the process. A typical business process often includes a number of decision points. These decision points generally have an effect on the process flow; for example, someone's credit rating may determine whether he or she is approved for a low-cost loan. These decisions are evaluated based on certain conditions and facts, which may be internal or external to the business process, and predefined company policies or rules. Business rules engines (BREs) allow architects to easily define, manage, and update the decision logic that directs enterprise applications from a single location without needing to write code or change the business processes calling them. BREs have been used extensively in enterprises; e.g., to implement yield management in the travel industry (what price to sell a ticket?), credit risk assessment in the loan industry (what is the interest rate for my car loan?), operations scheduling in manufacturing (what should we build today to maximize throughput and keep customers happy?), and the list goes on.
BREs are naturally of interest to enterprise architects building out SOAs, since they contribute to agility by enabling reduced time to automate, easier change, and easier maintenance for business policies and rules. BPM technology and BREs naturally fit together: BPM enables automated and flexible business processes; BREs enable automated and flexible business policies.
We'll outline three different approaches that you can take to incorporate rules into your process logic: code-based, model-driven, and service-oriented. We consider two classes of BPM systems: monolithic BPM suites - those that embed capabilities including a BRE into a suite, and open-standards BPM solutions, which are based on the BPEL standard and enable you to use your choice of rules engine or an embedded one. We show how each of two solution classes supports code-based, model-driven and service-oriented automation of business rules. A case study of a loan application processing will be outlined to show how business processes and rules exist together, and how the rules engine enables changes in business policies to be made easily by business analysts, without breaking the business process logic. We will then focus on how practitioners can go about building out their SOA using BPEL and their choice of rules engine, as well as how to integrate these capabilities (from an architectural perspective). We will also provide best practices on when to embed decisions in the process logic and when it's best to abstract and capture decisions/policies using a rules engine.
Context
Let's provide some background about the various concepts in a rules engine. Some common terms are:
A typical rules engine has the following components:
These components are common to both the monolithic BPM suites and the open-standards BPM solutions built on BPEL.
Approaches to Rules Enabling Business Processes
We consider three basic approaches to using rules in business processes, which are shown in Table 1. Regardless of the approach taken, some requirements include: tools for business analysts to define rules in an English-like language and tools for process owners to incorporate rules as part of the process flow; capabilities to modify rules after process deployment in response to changing company policies without the need to change the process definitions; mechanisms to load facts into the rules engine from business processes as well as other applications; and the ability to reuse rules across processes and applications. We can evaluate each of three approaches with respect to common criteria regarding ease of development, reuse, and flexibility. Table 2 summarizes the merits of each approach.
Monolithic BPM suites support both the code-based and the model-driven approaches and work best when rules are used in the context of business process only and when rules do not require additional context (for example, real-time metrics from a Business Activity Monitoring [BAM] solution). They do not generally make it possible for you to leverage existing rules (metadata) that may reside in an existing rules engine, which means you have to build your rules base from scratch or implement logic to import the rules. Furthermore, there are usually no out-of-the-box mechanisms for synchronizing rules between the embedded rules engine in the BPM system and external rules engines and repositories.
Open standards-based BPM solutions, such as many of those based on BPEL, enable all three approaches: code-based, model-driven, and service-oriented. They allow you to use your choice of rules engine if you decide to go for the model-driven or the service-oriented approach. You can also leverage existing rules/rules repositories/rules engines for use in business processes. If you need to use facts external to the BPM solution, then you generally don't have to worry about synchronizing rules metadata if you take the service-oriented approach. However, if you don't, then you can use the integrated rules capabilities and benefit from the integrated design time for rules and processes.
Case Study
In the previous section we discussed various approaches for rules enabling your business processes. Some of the key criteria to keep in mind when deciding which approach to use are the design experience, flexibility, reuse, and ease of maintenance of rules. Let's illustrate the trade-offs of the various approaches using a case study.
Consider the example of a loan flow process that is deployed at a loan agency. The loan agency accepts a request from a client, performs a credit check with an external service, and then does an automatic approval or routes it to a manager for review. Depending on the outcome, the loan flow process notifies the customer. The scenario consists of the following participants: the customer, the loan agency's approval process, and the credit rating service. Various facts that may be used to make loan approval decisions include the loan amount, the customer's annual income, the customer's credit rating, the status at this agency (returning customer or new customer), and the agency's outstanding loans (after all, if the agency has approved many high risk loans recently, it's probably a good idea to take this into account in approving future loans). Now let's consider various decision points in the process:
1. The first step is to get the credit rating from the credit rating service. The credit rating service may return a rating if the customer has a past history or it may return a NULL value if the customer is not known. If the loan agency does not want to ever deal with customers without a credit rating, it may have a rule such as: (see Insert 1)
This rule is very simple and not likely to be changed after process deployment. Hence, the fastest way to implement this would be by using the code-based approach with XPath or other expressions. Now let's consider a slightly more complex rule.
2. The loan agency may then use the customer's social security number (SSN), prior credit history, annual income, and outstanding loans to determine the customer credit rating, the risk, and maximum amount to lend a specific customer (see Insert 2).
In the above rule, there are various inputs that are provided by the business analysts; for example, the minimum annual income requirements and credit score. The analysts would like the ability to change these without necessarily redeploying the process. In this case, the model-driven or service-oriented approach would offer the most flexibility, since the rules would be separate from the process logic and can be modified independently. The code-based approach would not work since it would not be maintainable in the long run, and as the rules get more complex, defining them through just simple expressions would be very difficult. Now let's examine a slightly more complex scenario.
3. Based on the current business environment and other company policies, the loan agency may interpret the results differently and further apply rules to determine if the customer should be granted the loan, what interest rate should be given, and the appropriate approval policies. Note that in case 2 above, all the information needed to apply the rules was available from the business process itself. However, in some cases, rules may require additional facts that are asserted by other applications. Say you want to know if the "outstanding loans this month" are greater than US$3M or if the customer already has some other products - say, home equity loan or insurance products - from this company. These facts are provided to the rules engine by other applications, but are used by the rules engine in the decision to approve or reject a loan. For example: (see Inserts 3 & 4)
In this case, the decision service is used to evaluate rules based on both static data; that is, the loan application, as well as data such as "outstanding loans to high risk customers" from the BAM system. Similarly, rules are also used for dispatching the loan application for manual processing for high-risk customers. In this scenario, the code-based approach will obviously not work because it is not flexible enough and would be very difficult to maintain in the long run. The model-driven approach also is not very effective, since the rule engine requires facts/data from external systems such as a BAM solution or customer database. You could make the loan business process retrieve all this data and pass it to the rules engine; however, this would make the process very complex and would require changes every time the business analyst decided to use additional criteria for loan approval. The service-oriented approach works best in this case. You could have a central rules repository with a decision service that is used by all clients of the rules engine. The BPM solution, as well as other applications like BAM, would assert different facts to this service that executes the appropriate rule sets to make decisions.
This process and the various decision points are also illustrated in the architecture diagram in figure 1. As you can see, the first rule is implemented using inline process logic, and the rules service is used for cases 2 and 3 discussed above.
We suggest the following rules of thumb when deciding how to leverage rules logic in business processes:
Business Rules as a Decision Service Using the Service-Oriented Approach
Now let's talk about how you can embed rules in your composite application using a decision service. A decision service is a mechanism for publishing rules and rule sets as a reusable service that can be invoked from multiple business processes and applications. To set this up you have to: (1) define the facts and the corresponding rule sets that will be used by various applications, (2) publish these as a decision service that can then be invoked from the business process.
The aforementioned architecture is illustrated in Figure 1. The rules engine works off a common rules repository, and all rules are exposed via a decision service. The process developer defines the rules metadata, creates the service, and designs the BPEL process to interact with the rules. The business analyst generally uses the rules metadata to define the rules and customize rules on an ongoing basis after the process is deployed. The BPEL processes, BAM, and other applications assert facts and execute rules by interacting with the decision service.
Summary
We have provided details on the approaches that you can take for implementing decision logic in business processes, and given some guidance on when to apply each approach. Monolithic BPM suites limit your flexibility in integrating process and rules logic because they don't allow you to easily assert facts from external sources or use your existing rules engines. We believe that an open standard, BPEL-based BPM solution is ideal. Such an open approach enables you to develop rules in a code-based, model-driven, or service-oriented manner. It provides an embedded business rules capability, yet allows you to replace the rules engine with your choice of third-party rules engine, or make the embedded and your third-party rules engine coexist. By delivering on this, it yields ease of development through common tooling for process and rules, and improved performance, yet delivers full flexibility. Who says choice is a bad thing?
References
Further details on how to implement a service-based business rules service in the context of BPEL can be found at www.oracle.com/technology/index.html under the link "SOA Best Practices: The BPEL Cookbook."