Skip to main content

Make composite business services adaptable with points of variability, Part 3: Using selectors and business rules for dynamicity

Ying Chun Guo (guoyingc@cn.ibm.com), Software Developer, IBM, Software Group
author photo
Ying Chun Guo works as a software engineer at the China Technology Institute, China Software Development Laboratory. She is currently working on composite business services (CBS) and Service-Oriented Architecture (SOA).
Qiang Wang, Staff Software Engineer, IBM
Qiang Wang photo
Qiang Wang works as a staff software engineer at the China Emerging Technology Institute, China Software Development Laboratory. He concentrates on IBM incubator projects and Service-Oriented Architecture (SOA)-related topics. His interests include J2EE, SOA, MDA/MDD, AOP, RUP, and project management. He is currently working on an SOA pilot called CBS (composite business services).
Germán Goldszmidt, Ph.D., Distinguished Engineer, IBM, Software Group
author photo
Dr. Germán Goldszmidt is a distinguished engineer working in the IBM Software Group, with focus on architecture of an integrated platform to deliver, customize, and deploy Service-Oriented Architecture (SOA) composite business services (CBSs).

Summary:  Explore options for building points of variability (POV) in Service-Oriented Architecture (SOA) composite business services in this series. In this article use selectors and business rules in IBM® WebSphere® Process Server to incorporate dynamicity and configurability for business processes in a composite business service (CBS). Discover issues you can encounter while using selectors and business rules, the criteria for choosing selectors to implement dynamic binding, and implementation best practices.

View more content in this series

Date:  12 Jun 2007
Level:  Intermediate
Activity:  2039 views

Introduction

Part 1 of the series "Building SOA composite business services," (see Resources) describes a composite application called Jivaro, which is also the name of a fictitious bank. In this article, using the Jivaro banking application as an example, you'll learn how to use selectors and business rules to achieve dynamicity and configurability. Mediation modules in WebSphere Enterprise Service Bus (ESB) and dynamic service mediation using WebSphere Business Services Fabric (WBSF) are alternative options for achieving dynamicity and configurability. Upcoming articles in this series will examine ESB and WBSF.

Use cases in Jivaro

"Building SOA Composite Business Services, Part 1" identifies use cases that are initiated by a bank customer. The Apply for Loan use case invokes a BPEL business process. The business process goes through a series of steps that involve invoking services in order to process the loan application.


Using selectors

A selector decouples the client application from a specific target implementation. At run time, based on a predefined set of criteria, the selector determines which target implementation to invoke, such as the date and time of the invocation. This allows a change of target implementations without a change to the client. Selectors also exhibit run-time dynamicity of service endpoint choices (as explained in Part 1 of this series). New target implementations can be added to a selector at run time, without requiring a restart of WebSphere Process Server (Process Server) server instance where the selector is deployed.

In the Jivaro application, the CreditCheckQueryService has multiple target implementations offered by different Jivaro partners. On a particular day of a year, the Jivaro bank needs to change to a different credit check provider of the CreditCheckQueryService. The Jivaro bank wants to avoid down time while making the change. This section shows how the requirements can be satisfied using selectors.

Overview of CreditCheckQueryServiceSelector

The CreditCheckQueryServiceSelector is realized in the SasBankWSSelectors Service Component Architecture (SCA) module, as shown in Figure 1. The default destination for this selector is CreditCheckQueryService (in the upper right of Figure 1). The alternative destination is newCreditCheckQueryService (shown below the CreditCheckQueryService). The particular days of the year when Jivaro bank would like to use the newCreditCheckQueryService are shown on the bottom half of Figure 1, where the selection time scope is from June 1, 2006 at 12:00 A.M. until Jan 1, 2007 12:00 A.M.


Figure 1. Implementation of CreditCheckQueryServiceSelector
The     implementation of CreditCheckQueryServiceSelector

Scenario 1: Invoke the original CreditCheckService

This scenario uses the embedded Web service test explorer in WebSphere Integration Developer V6 (Integration Developer) to test the Web service CreditCheckQueryServiceSelectorExport exported by the CreditCheckQueryServiceSelector in the SasBankWSSelectors SCA module, as shown in Figure 2.


Figure 2. Test original Web service in embedded Web service test explorer
Test original Web service

Because the date of the test is 05/22/2006, the Web service invocation is directed to the default service, which is the CreditCheckQueryService. This service returned a credit score of 550.

Scenario 2: Change the target implementation to the new CreditCheckService

To redirect the Web service invocation to the second service, NewCreditCheckQueryService, you need to change the selection criteria. We'll use the selector config Web tooling embedded in the Process Server 6 admin console.

Go to Application > Server1 > Selectors in the Process Server admin console, as shown in Figure 3. Click the CreditCheckQueryServiceSelector link.


Figure 3. CreditCheckQueryServiceSelector in selectors list
Click CreditCheckQueryServiceSelector in the selectors list

Under Selector Tables, click retrieveCreditScore, as shown in Figure 4.


Figure 4. retrieveCreditScore in operations list
Click retrieveCreditScore in the operations list

Click the corresponding selection criteria link, as shown in Figure 5 and Figure 6.


Figure 5. Targets list
Click the second target in the targets list

Click the second target in the targets list before changing the date.


Figure 6. Properties
Before changing the date

You just went through the steps to reconfigure the selection criteria for the operation retrieveCreditScore and changed the start date from June 1, 2006 to January 1, 2006. The changed configuration is shown in Figure 7.


Figure 7. Changed date
After changing the date

After committing the configuration change through the Process Server admin console, you can go back to the Web service test explorer in Integration Developer and rerun the test case. The return value of 619 is different from the value 550 returned by the first call, even though the same input parameter -- 001002111 -- was used (see Figure 8). The Web service invocation has been successfully redirected by the selector to the second service, NewCreditCheckQueryService, because the current time of 05/22/2006 is in the scope of the changed selection criteria (from 01/01/2006 to 01/01/2007) for the second target service.


Figure 8. Test current Web service in embedded Web service test explorer
Test current Web service in embedded Web service test explorer

Using business rules

In Integration Developer, the business rule logic is specified in a simple form, such as a sequence of if-test-then-actions clauses or a simple decision tree.

From Wikipedia: Business rules or business rulesets describe the operations, definitions, and constraints that apply to an organization in achieving its goals (see Resources).

Business rules allow the separation of the business rule logic from the other services, applications, and processes in the system. Details of business rules can be changed frequently and dynamically.

In the scenario, we applied business rules to the Jivaro application to achieve configurability, flexibility, and dynamicity (see "Building SOA Composite Business Services" in Resources).

In the Apply for Loan use case, several business rules are in the process that handle the loan application. For example:

If the credit score of the applicant is less than 500, the loan application will be automatically rejected.

Because Jivaro banking is a multi-tenant environment, the parameters of a rule (for example, 500) may be different among different tenants. Thus, a tenant (the bank) ID is also included as a condition of business rules. The sample rule is changed, as follows:

If the bank ID is 001 and the credit score of the applicant is less than 500, the loan application will be automatically rejected.

The numbers in italics represent configurable parameters in the business rule, which can be changed at run time.

You can develop rules and rule templates in Integration Developer and change the configurable parameters at run time in the Process Server business rules manager application.

Developing business rules in Integration Developer

Business rule templates in Integration Developer allow analysts to change business rules without having to restart the project or application server. A template defines variables that can be modified. Using templates, similar rules can be created just by making changes to the parameters, without having to redefine the implementation.

First create a rule template called AutoRejectTemplate, as shown in Figure 9, with bank id and score number parameters that can be changed at run time.


Figure 9. Rule template AutoRejectTemplate
AutoRejectTemplate

Next, create the rule Bank1AutoReject from the template AutoRejectTemplate, as shown in Figure 10.


Figure 10. Rule Bank1AutoReject
Bank1AutoReject

Change of business rules in business rules manager

Business rules manager is a Web tool provided by Process Server to allow change to business rules at run time. Figure 11 shows the Bank1AutoReject rule.


Figure 11. Bank1AutoReject rule in business rules manager
Bank1AutoReject rule in Business Rules Manager

For example, a business analyst can change business rules by editing the configurable parameters, such as the bank id and the credit-score threshold shown in Figure 12.


Figure 12. Edit Bank1AutoReject rule in business rules manager
Edit Bank1AutoReject in Business Rules Manager

The analyst can also create a new rule from a business rule template by filling in the parameters, as shown in Figure 13.


Figure 13. Create a rule based on a template
Create a rule based on a template

Other options to consider

You can also use mediation modules in ESB and WBSF (as well as Process Server) to achieve dynamicity. Mediation modules provide the capability to transform, route, and augment a message from an external data source. You can code more complex routing logic using a mediation module rather than a selector. For example, dynamic binding to a target implementation based on the contents of the message can be achieved using mediation modules. However, this requires developing custom code. A mediation module cannot be changed as easily at run time as business rules and selectors.

WBSF provides a dynamic service selection based on context and content in message headers and policies specified as assertions. WBSF policies are extensible through ontology extensions. Service selection criteria can also be changed at run time by changing assertion metadata and by adding new endpoints. WBSF also provides governance functions over run-time changes. However, developing solutions using WBSF involves several steps to modify metadata definitions and message headers.

Future articles in this series examine dynamicity scenarios in Jivaro using mediation modules.

Selectors and business rules provide solutions for meeting simple dynamicity and configurability requirements.


Issues and best practices

This section discusses a few issues uncovered during the development of Jivaro and some "best practice" tips.

Decision tables compared with rule sets

It's best to choose rule sets when business rules have few clauses or variables in the conditional statements, or if multiple business rules must be executed. Choose rule sets instead of decision tables when the sublevel clauses are not the same in every branch. For example, in the Apply for Loan use case, the credit score thresholds for auto-reject are different in bank 1 and bank 2, as shown in Figure 14.

If the bank ID is 001, the credit score of the applicant is less than 500, the loan application will be automatically rejected.
If the bank ID is 002, the credit score of the applicant is less than 450, the loan application will be automatically rejected.

Figure 14. Decision tree
Decision tree

The sub-level conditions must always be the same in every branch in decision tables, as shown in Figure 15.


Figure 15. Decision table
Decision table

Selectors and exports

A selector can reach an export in another SCA module, without requiring an import. A selector decides which targets should be invoked at run time. The choice of targets is based on:

  • All components in the same SCA module with a matching interface
  • All matching exports deployed to Process Server

Consequently, all exports with matching interfaces in other SCA modules can be wired to the selector. A selector does not need an explicit SCA import defined in order to reach an export in another module.

Tooling or run-time configuration support

Tooling or run-time configuration support is unavailable for nondate-range-based selectors and custom selectors. Currently there are three kinds of selectors supported by Process Server V6:

Generic date-range-based selectors
Make their invocation decision based on a date range. These selectors are fully supported by the Integration Developer tooling and by the Process Server admin console. Extra ranges can be added at run time, candidate targets can be changed at run time, and the resulting modifications can be re-exported back to the tooling.
Generic non-date-range-based selectors
Do the selection based on other data types and conditions. They allow selection based on other ranges (such as integers, longs, doubles) and are based on discrete values. For example, "If the string in the business object is X, then route to the Y destination." You can achieve this function by editing an XML-based .selt file.
Custom selectors
Can be used to write custom algorithms.

For the non-date-range-based selectors and custom selectors, there is currently no tooling or run-time configuration support. A key benefit of using selectors is the ability to add, remove, and change targets at run time by using the Web-based tooling that's embedded in the Process Server admin console. A selector modified by editing the .selt file or by extension, through a custom selector, loses this ability.

To retain the ability to change targets at run time, currently the best choice is to use a custom Java code snippet to render selection logic as an expression that returns a date to be used as the selection criterion for the date-range-based selectors.


Summary

This article explains how selectors and business rules are used in the Jivaro banking system to achieve dynamicity and configurability. The solution, when compared with WebSphere Enterprise Service Bus mediation or WebSphere Business Services Fabric, is more accessible to developers who are unfamiliar with Java. You also learned about the issues uncovered in the development of Jivaro composite business services and some suggested best practices.

Stay tuned for the next installment in this series, which will describe an approach for implementing dynamicity with WebSphere Enterprise Service Bus mediation modules. The article will explore the limitation of the selectors and business rules in respect to endpoint aliasing across different protocols (for example, SOAP/HTTP compared to SOAP/JMS), and give an example of a mediation module suitable for programmatic aliasing regardless of the underlying protocol.


Resources

Learn

Get products and technologies

  • Get started now! Download more IBM product evaluation versions and get your hands on application development tools and middleware products from DB2®, Lotus®, Rational®, Tivoli®, and WebSphere.

Discuss

About the authors

author photo

Ying Chun Guo works as a software engineer at the China Technology Institute, China Software Development Laboratory. She is currently working on composite business services (CBS) and Service-Oriented Architecture (SOA).

Qiang Wang photo

Qiang Wang works as a staff software engineer at the China Emerging Technology Institute, China Software Development Laboratory. He concentrates on IBM incubator projects and Service-Oriented Architecture (SOA)-related topics. His interests include J2EE, SOA, MDA/MDD, AOP, RUP, and project management. He is currently working on an SOA pilot called CBS (composite business services).

author photo

Dr. Germán Goldszmidt is a distinguished engineer working in the IBM Software Group, with focus on architecture of an integrated platform to deliver, customize, and deploy Service-Oriented Architecture (SOA) composite business services (CBSs).

Comments (Undergoing maintenance)



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, WebSphere
ArticleID=230291
ArticleTitle=Make composite business services adaptable with points of variability, Part 3: Using selectors and business rules for dynamicity
publish-date=06122007
author1-email=guoyingc@cn.ibm.com
author1-email-cc=
author2-email=wangq@cn.ibm.com
author2-email-cc=flanders@Aus.ibm.com
author3-email=gsg@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