Skip to main content

On demand business process life cycle, Part 6: Apply customization policies and rules

Germán Goldszmidt, Ph.D., Senior Technical Staff Member, IBM, Software Group
Dr. Germán Goldszmidt is a Senior Technical Staff Member working in IBM Software Group, with a focus on the architecture of an integrated platform for delivering, customizing, and deploying on demand solutions. Previously, he was a researcher at the IBM T.J. Watson Research Center, and led the design and implementation of several technologies, including Océano, the first prototype autonomic computing eUtility, and Network Dispatcher, the load balancer component of WebSphere products.
Joshy Joseph, Senior Engineer, IBM, Software Group
Joshy Joseph is a Software Engineer working in IBM Software Group in the IBM On Demand Architecture and Development organization. He is an architect and programmer with primary skills and expertise in the areas of distributed computing, Grid computing, Web services, Business Process, and workflow development. He is the author of the book Grid Computing from Prentice Hall, 2003. In addition, he has written numerous technical articles about grid computing, Business Process development, and Web services.
Naveen Sachdeva (sachdeva@us.ibm.com), Advisory Software Engineer, IBM, Software Group
Naveen Sachdeva is an Advisory Software Engineer with the IBM Application Integration Middleware group. He has over 10 years of experience in large-scale systems integration and in the design and development of distributed computing systems. He currently helps IBM business partners with technical enablement and proof-of-concept using the WebSphere Studio family of products.

Summary:  Develop and manage rules to enforce the policies for on demand processes. As business owners introduce new requirements to respond to changing business conditions, on demand processes must adapt accordingly. Rapid customizations are achieved during execution through dynamic changes to the rules that enforce the business policies. Externalizing the rules allows analysts and other less-technical users to effectively modify the policies without changing the process logic.

Date:  08 Feb 2005
Level:  Advanced
Activity:  693 views
Comments:  

Introduction

In the first paper in this series (see Resources) we introduced an on demand business process scenario for an Order to Manufacturing Processing System (OTMPS). Over time, the OTMPS executives or owners will introduce new requirements on the OTMPS implementation. For example, they might ask to change the policies (for a definition of policy see the sidebar entitled "Policy, rules, and enforcement points") for deciding which manufacturing plant to use for specific orders. Policies might change as a result of competitive requirements, external regulations, new business models, and other factors.

Analysts might specify intended policies as natural language annotations in the business process model using IBM® WebSphere® Business Integration Modeler (Business Integration Modeler), as described in Part 3 of this series (see Resources). However, policies don't have to be enforced if rules are executed at the appropriate locations. We cannot automate the implementation of these rules from the policy statements. In some cases, policies are not explicitly specified, but are rather implicitly defined by a set of implemented rules.

Policy, rules and enforcement points

A policy is a declarative statement, usually written in a natural language; for example, "only USA customers can order machine X." For a policy to be effective, an implementation must provide appropriate enforcement point. An enforcement point can be implemented as an explicit step in a business process or a specific location in the implementation code. For example, an activity in an OPS business process can execute a rule to determine the correct partner for order validation. An enforcement point can also occur when processing events. For example, upon receiving a customer order processing completion event, the system can evaluate another rule to determine which customer notification method is appropriate, such as e-mail or telephone. A rule is imperative and logically executable; for example, "If !(location(customer) == "USA") then reject(order);. Rules are a useful way to implement a policy enforcement point.

In traditional applications, rules are embedded with the logic inside the application. In such applications, when policies change, the application code needs to be updated and re-deployed to reflect the change. Externalizing the rules allows analysts and other less-technical users to dynamically modify policies that have been defined without changing the process logic.

Given the long-running nature of business processes, there is usually a need to change these policies dynamically. To reuse the existing workflow and service artifacts, it is essential that the architecture enables late customization for policy changes. These customizations are achieved during workflow execution through dynamic changes to the rules that implement and enforce polices. Some polices can be enforced through configuration parameters (see the side-bar entitled "When to use rules versus configuration parameters" for details).

In this article, we describe Business Rules Beans (BRBeans) framework and the implementation of a rule service facade. In addition, we illustrate an example through the following step-by-step methods:

  • Specify a policy using Business Integration Modeler.
  • Create the necessary rules to implement that policy.
  • Enforce those policies through enforcement points in the process and workflow model.

Business Rules Beans


Figure 1. BRBeans architecture
BRBeans Architecture

BRBeans is a rules framework (see Figure 1) in IBM WebSphere Business Integration Server Foundation. It is implemented using Enterprise Java Beans components such as Rule, RuleFolder, and RuleHelper. Each rule is represented by an entity bean that persistently stores information related to that rule. Each rule is assigned an appropriate rule name and associated properties (for example, start date, end date, available, javaRuleImplementorName) and is stored in an appropriate rule folder. A rule implementation is an algorithm written in Java language and associated with the rule through a javaRuleImplementorName rule property. Listing 1 shows a sample rule implementation.


Listing 1. A sample rule implementation
public class RuleSelectManufacturingPlant implements RuleImplementor {
	public Object fire(TriggerPoint arg0, Object arg1, IRuleCopy arg2,
		Object[] arg3) throws BusinessRuleBeansException {
		String mfgPlant = null;
		? //set mfgPlant using the initialization and input parameters i.e. arg3
		return mfgPlant;
	}
	public void init(Object[] arg0, String[] arg1, String arg2, IRuleCopy arg3){
		? //set initialization parameters
	}
}
			

When to use rules versus configuration parameters

You can use rules to encapsulate chunks of logic that are subject to frequent changes. Rules are executed in a way that facilitates run-time binding. In other words, you can modify a rule during run-time execution without having to re-deploy the application. You should identify those pieces of logic that are expected to be changed frequently and expose these chunks as rules.

You can enforce some policies through configuration parameters. For example, "in case of 'database not available' error, the system should retry 3 times before raising an alarm." While the number of times to retry might change over time, the decision to retry and wait is essentially fixed. Configuration parameters are captured in a text/properties file which is read when the system starts and can be changed later if needed. In some cases, using configuration files may suffice, and there is no need for rules. Some software systems (such as Apache JSTL) support evaluation of these configuration parameters using simple rule implementations.

When the rule is fired, it takes its persistent data plus any parameters, and together these are passed to the RuleImplementor code. A rule management application is provided to create and modify rules. A Trigger point framework is provided to execute a rule from the application code. This framework implementation can dynamically associate a rule name with a particular rule implementation. As Listing 2 shows, BRBeans clients execute the rules by invoking the trigger() method in the TriggerPoint class. This class is used to transfer control to the trigger point framework to find and fire the rules specified in the application's trigger point.


Listing 2. Using BRBeans
TriggerPoint tp = new TriggerPoint();
params [ ] = { var1, var2, var3 };
String ruleName = "com/xyz/Rule?";
Object result = tp.trigger(this, params, ruleName);
			


Rules service facade

We suggest a service invocation which uses the BRBeans APIs, as shown in Figure 2, as an alternative to directly invoking the BRBeans APIs. This provides a service-oriented method for invoking the rules without directly invoking the middleware-provided APIs. This service façade approach provides a loosely coupled rule access mechanism that fits well with the Web services programming model and process modeling. In addition, by using the façade pattern, you can later plug-in extended capabilities, such as rule mediation, versioning, and others.

There are many ways to logically partition and package the rules as part of service façade. For example:

  1. You could wrap all the application specific rules in a service façade with each rule being exposed as a method or,
  2. You could wrap each rule in a service façade with an access method.

All rules that can be shared across applications (such as security, business performance, and so on) can be defined in other common services façade.


Figure 2. Rules service facade
Rules service facade

Figure 3 illustrates the interaction between the workflow component, the OTMPS Rule service façade that we defined, and BRBeans rule framework.


Figure 3. Rule service facade
Rule service facade

In the OTMPS service façade, we wrapped all rules in a single service (OTMPSRules), where each rule is exposed as a method of the service, as shown in Listing 3.


Listing 3. An OTMPSRule service
public class OTMPSRules {
	public String SelectManufacturingPlant (Order  order) { 
		return ?.;
	};
public String DetermineConfigurator(Order  order) { 
		return ?.;
	};

}
			

This rule façade service exposes the rules using WSDL portTypes, as shown in Listing 4.


Listing 4. An OTMPSRule portType
<portType name=" OTMPSRules">
        <operation name="SelectManufacturingPlant" parameterOrder="order">
        </operation>
        <operation name=" DetermineConfigurator" parameterOrder="order">
        </operation>
</portType>
			

At enforcement points, rules are invoked as normal Web services, passing the necessary parameters for execution. The OTMPPSRules service façade is invoked from the workflow using the Business Process Execution Language (BPEL) partnerLink and the BPEL invoke operation.

Each rule service façade operation creates an instance of the TriggerPoint class and invokes the trigger() function on that class with the reference to invoker, input parameters, and the rule name. Listing 5 illustrates this implementation.


Listing 5. OTMPSRule implementation
public class OTMPSRules {
public String SelectManufacturingPlant (Order order) { 
	TriggerPoint tp = new TriggerPoint();
params [ ] = { order };
String ruleName = "com/ibm/otmps/RuleSelectManufacturingPlant";
String result = (String)tp.trigger(this, params, ruleName);
	return result;
	};
public String DetermineConfigurator (Order order) { 
??.. 
	}	
}
			


Policy implementation example

In our sample scenario, the business owners defined a policy for manufacturing plant selection for specific orders. For example, a policy might specify that orders with a value exceeding US$1 million should be processed by certain manufacturing plants according to some priority criteria, for example, turn-around time. Another example policy might specify how to handle orders when the preferred plant is not in production.

Figure 4 shows the roles, tools, and the specific activities conducted by each role while implementing the policies. Analysts collect the required polices from the business owners and document these policies in the process models created in Business Integration Modeler. You can later add the necessary code to actually implement these policies by implementing rules and rule services and connecting the workflow to the rule services. Deployment managers are responsible for deployment and administration of these rules.


Figure 4. Implementation business policies -- roles, tools, and activities
Implementation business policies

Document policies in Business Integration Modeler

The analyst documents the policies through annotations. Each of these policy statements annotations should eventually be implemented through enforcement points. For example, they can be implemented as rules external to the workflow. Figure 5 shows an example of a policy annotation in Business Integration Modeler.


Figure 5. Process model with policy annotations
Process model with policy annotations

We suggest two ways to add enforcement points to the process model:

  1. Add to the model service elements which represent pre-existing services that provide enforcement points.
  2. Add tasks to represent placeholders for code which will enforce policies.

Figure 5 shows a task (Apply manufacturing Plant Selection Policy) that is defined to be a placeholder for enforcing the policy (Select Manufacturing Plant). You can later add the necessary code to actually implement the task.


Create rules and rule services

Using the annotations in the process model as requirements, the developer codes the necessary rules and rules service implementation.

As the developer, you should complete the following tasks:

  1. Create the rule implementation using BRBeans APIs for the corresponding polices defined in the modeler.
  2. Deploy and configure the rules in the BRBeans framework.
  3. Create a service façade for the created rules.
  4. Create the necessary interfaces and bindings for the rule service.

We detail these steps here:

1. Rule implementation


Listing 6. Rule implementation
package com.ibm.coats.poc2004.ruleimplementors;

import coats.objects.order.item.OrderItem;

import com.ibm.websphere.brb.BusinessRuleBeansException;
import com.ibm.websphere.brb.RuleImplementor;
import com.ibm.websphere.brb.TriggerPoint;
import com.ibm.websphere.brb.mgmt.IRuleCopy;
import java.util.StringTokenizer;

public class RuleSelectManufacturingPlant implements RuleImplementor {
	
	private StringTokenizer Plant1Codes;
	private StringTokenizer Plant2Codes;
	private String delimeter = ",";

	public Object fire(
		TriggerPoint arg0,
		Object arg1,
		IRuleCopy arg2,
		Object[] arg3)
		throws BusinessRuleBeansException {
			
		String mfgPlant = null;
		String mfgCode = ((OrderItem)arg3[0]).getMfgCode();
				
		if (findCode(Plant1Codes, mfgCode)) {
			mfgPlant = "Plant1";
		} else if (findCode(CRSCodes, mfgCode)) {
			mfgPlant = "Plant2"; 
		} else throw new BusinessRuleBeansException("No manufacturing 
		plant found for \"" + mfgCode + "\"\n\n");
		
		
		return mfgPlant;
	}

	public String getDescription() {
		return "This rule finds the manufacturing plant to send the order to by 
		comparing the manuPlant code for the order against the 
		initialization parameters.";
	}

	public void init(Object[] arg0, String[] arg1, String arg2, IRuleCopy arg3)
		throws BusinessRuleBeansException {
			
			String plant1CodeString = (String)arg0[0];
			String plant2CodeString = (String)arg0[1];

			Plant1Codes = new StringTokenizer(plant1CodeString, delimeter);
			Plant2Codes = new StringTokenizer(plant2CodeString, delimeter);
	}
	
	private boolean findCode(StringTokenizer st, String code){
	
		String token;		
		
		while (st.hasMoreTokens()) {
	            	
				token = st.nextToken().trim();	
				if (token.equals(code)){return true;};
		}	
		
		return false;
	}
	
	

}
			

Listing 6 shows the implementation of the rule Select Manufacturing Plant. In BRBeans a rule is implemented as a Java class (for example, RuleSelectManufacturingPlant). Each rule class implements the RuleImplementor interface which includes two methods: fire and init. The fire method is triggered for the rule execution and the necessary logic is provided for the execution of business rules, such as selection of the manufacturing plant. The fire method uses the persistent data stored in the rule bean and the parameters passed as arguments for the execution of the rule. The ?init? method provides an initialization routine for rule bean.

2. Rules management in BRBeans: BRBeans provides a Java application -- rulemgmt, for managing application rules. This rulemgmt application is invoked with a properties file as input that refers to the access information for BRBeans. Listing 7 shows the properties file for OTMPS.


Listing 7. OTMPSBRBeans properties
host=localhost
port=2809
RuleJndi=brbeans/OTMPS/Rule
RuleFolderJndi=brbeans/OTMPS/RuleFolder
RuleHelperJndi=brbeans/OTMPS/RuleHelper
			

In order to run this application, the BRBeans server should be running. Figure 6 shows the GUI of rulemgmt. This application can be used to create new folders and rules. Three required attributes for a rule are: 1) fully qualified name, 2) implementation class, and 3) initialization properties. A double-click on a rule brings up the rule configuration window. Figure 7 shows the rule configuration window for the selectManufacturingPlant rule.


Figure 6. rulemgmt application
rulemgmt application

Figure 7. Rule configuration
Rule configuration

3. Rule service façade implementation: The above rule implementation can be invoked using a rule service façade, as shown in Listing 5.

4. Rule service interface: Once the service façade is implemented, a service interface and binding elements are generated. Listing 4 shows a simplified version of the WSDL generated for the OTMPSRule service.

You can create the WSDL interfaces using the IBM WebSphere Studio Application Developer Integration Edition feature Service build from?. For example, select the OTMPSRules service façade and invoke Service build from?. Check the methods that are to be exposed as service operations. This tool generates the WSDL interface and service and binding files required for accessing the OTMPSRules service.


Access rule service from BPEL workflow

Each task in the Business Integration Modeler model is mapped to a partner service in the BPEL workflow. As Figure 8 shows, the policy enforcement task (Apply manufacturing Plant selection Policy) shown in the Business Integration Modeler model (Figure 5) is mapped to an invoke service in BPEL.


Figure 8. BPEL with policy enforcement point (Apply manufacturing Plant selection Policy)
BPEL with policy enforcement

As explained earlier, this invoke activity can be connected to the correct rule service or can be pointing to a placeholder service. In the case of using a placeholder service, you connect the invoke activity to the correct rule service implementation through the BPEL partnerLink. There are three activities you perform to invoke the rule service:

  1. Create a new Partner Link for the rule service.
  2. Create the input and output variables that correspond to rule service operation messages.
  3. Connect the Apply manufacturing Plant selection Policy BPEL invoke activity to the newly created partner link.
    • Add partnerLink for rule services: Select the artnerLinks in the OrderProcessSystem process in the BPEL editor. Add a new partnerLink (RuleServicePartner). In the Implementation property sheet of the partner link, click Edit to edit the partner link type. Give the process a role name and link this process to the rule service interface. In addition, select the correct portType from the WSDL file.
    • Create the input and output variables for the rule service: Figure 9 shows two variables, RulesServiceInput and RulesServiceOutput, with their corresponding message details, including WSDL file name, message name, and parts name.
      Figure 9. Variables and their properties
      Variables and their properties
    • Connect the invoke activity to partnerLink: Once the partnerLink and associated messages are defined, select the invoke activity (Apply manufacturing Plant selection Policy) and associate the correct partnerLink, portType, request variable, and response variable and associate the correct operation to the invoke activity. Figure 10 shows the properties of the invoke activity after connecting to the rule service façade created earlier.

Figure 10. Modifying BPEL partnerLinks for BPEL invoke activity
Modifying BPEL parnterLinks

Customize rules

Various customization options are available through the BRBeans administration user interface (see Figure 6). Options include the following:

  • Select the rule effective period.
  • Add initialization parameters to the rule.
  • Change the rule implementation class.
  • Expire current rules.

The analyst could use these capabilities to enforce the customizations required for the business processes without changing the workflow code. For example, the analyst could change the initialization properties for the selectManufacturingPlant rule and redeploy the rule class without changing the workflow code.

The time it takes for a rule change to become effective depends upon the configurable PollFrequency of the system rule -- BRBCacheRule (in brb folder). The default value for PollFrequency is 10 minutes. Lowering this value means that a rule change becomes effective sooner, but it could have a negative performance impact, as the system will poll more often.


Conclusion

Workflow customization to support dynamic polices is a key element of the on demand business process life cycle methodology. This paper described a method to customize an on demand business process using policies enforced by rules within a SOA framework.


Acknowledgements

The authors would like to thank Mark H. Linehan, Margie Mago, Jon K. Peterson, and Catherine Rivi for their contributions, suggestions, and assistance with this content.


Resources

About the authors

Dr. Germán Goldszmidt is a Senior Technical Staff Member working in IBM Software Group, with a focus on the architecture of an integrated platform for delivering, customizing, and deploying on demand solutions. Previously, he was a researcher at the IBM T.J. Watson Research Center, and led the design and implementation of several technologies, including Océano, the first prototype autonomic computing eUtility, and Network Dispatcher, the load balancer component of WebSphere products.

Joshy Joseph is a Software Engineer working in IBM Software Group in the IBM On Demand Architecture and Development organization. He is an architect and programmer with primary skills and expertise in the areas of distributed computing, Grid computing, Web services, Business Process, and workflow development. He is the author of the book Grid Computing from Prentice Hall, 2003. In addition, he has written numerous technical articles about grid computing, Business Process development, and Web services.

Naveen Sachdeva is an Advisory Software Engineer with the IBM Application Integration Middleware group. He has over 10 years of experience in large-scale systems integration and in the design and development of distributed computing systems. He currently helps IBM business partners with technical enablement and proof-of-concept using the WebSphere Studio family of products.

Comments



Trademarks  |  My developerWorks terms and conditions

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=SOA and Web services
ArticleID=35151
ArticleTitle=On demand business process life cycle, Part 6: Apply customization policies and rules
publish-date=02082005
author1-email=gsg@us.ibm.com
author1-email-cc=
author2-email=joshy@us.ibm.com
author2-email-cc=
author3-email=sachdeva@us.ibm.com
author3-email-cc=

My developerWorks community

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Rate a product. Write a review.

Special offers