IBM Business Automation Workflow Using IBM Operational Decision Manager Decision Service

Demonstrates how you can discover and use the IBM Operational Decision Manager decision service in IBM Business Automation Workflow.

rastudio © 123RF.com

Code Repository

Examples can be found in the TipsforBAW Toolkit Github repository.

Introduction

IBM Business Automation Workflow (BAW) and Operational Decision Management (ODM) solutions are naturally complementary because every transaction, order, customer interaction depends on decisions. The combination of workflow and decision brings additional flexibility, agility, and availability to the business and technical experts when building processes. In a separate posting, which is IBM Business Automation Workflow Implementing Decision Tasks, we show the capability of IBM BAW to create and use decision tasks in a workflow by implementing the decision logic in action rules or decision tables. In most cases, we can develop and implement business rules in IBM BAW processes and service flows. However, there are situations where you need to use the decision logic beyond your workflow application like:

  • Business rule complexity exceeds what it supports within IBM Business Automation Workflow
  • Business rules are continuously changing
  • Business rules need to modify in real-time

In these situations, we need the extensive decision automation capability of IBM Operational Decision Manager to manage decisions separately from the business application, with more flexibility and responsiveness to the changing needs of the business.

The transition of business rules/decisions in a workflow application and moving to them into a decision management system provides some benefits:

  • Rules development and maintenance are more effective.
  • Changes to the business rules do not require changes to your workflow application or process codes.
  • Business experts can define and manage decisions with limited dependence on IT.
  • Your application can remain up to date and aligned and meet changing business needs quickly.
  • You can share and reuse business rules/decisions across applications and platforms.

This article provides the following detailed information on discovering and using IBM Operational Decision Manager decision service in IBM Business Automation Workflow. It makes our business process more efficient, resilient to change, and accessible to enable the business to respond to the evolving requirements.

  1. Export Rules from BAW and Import them into ODM Rule Designer.
  2. Retrieve the Hosted Transparent Decision Service in ODM Rule Execution Server
  3. Invoke ODM Decision Service from BAW

Export Rules from BAW and Import them into ODM Rule Designer

One feature of IBM Business Automation Workflow (BAW) is to implement a decision task which discussed in the previous article, IBM Business Automation Workflow Implementing Decision Tasks. When you need to define your decision logic outside your workflow application, IBM BAW allows you to export the set of action rules and/or decision tables in your decision task and then import them into Rule Designer. IBM Operation Decision Manager (ODM) enhances your rules and adds the ability for business users to create, update, and deploy the business rules and to have a single set of rules available to multiple applications.

This section provides detailed steps on how you can export the rules from a decision task in IBM BAW and how you can import the rules in IBM ODM Rule Designer. To complete the steps below, we will export the rules of ‘ValidateLoyaltyRewards’ service flow created in the previous article.

Step 1: Export the Rules to a Project File

  • In Process Designer, select the Service Flow that contains the decision that you want to export.
Figure 1: ValidateLoyaltyRewards Service Flow
  • In the service flow, select the Decisions tab, then on the left pane, select the decision name you want to export. Click Export.
Figure 2: Export Action Rule and Decision Table
  • The rule project file is automatically downloaded and saved on the location specified in your browser settings, see Figure 3. In case your browser is configured to ask where to save each file before downloading, navigate to the location where you want to save the exported rule project then enter the filename, see Figure 4. Click Save.
Figure 3: The exported file is automatically downloaded
Figure 4: ‘Save As’ Window to export the project file

NOTE: The export procedure produces a complete rule project suitable for maintaining and continuing the work in IBM Operational Decision Manager Rule Designer.

Step 2: Import the Rule Project File in Rule Designer

  • Open the Rule Designer then select an empty workspace. Click OK.
Figure 5: Rule Workspace
  • In Rule Explorer, import your rule project file. There are two ways to import:
  1. Click File > Import > General > Existing Projects into Workspace then click Next.
Figure 6: Import Project File

2. Right-click on your workspace, then select import> Existing Projects into Workspace, then click Next.

Figure 7: Import Project File
  • In the Import Projects window, click Select archive file. Click Browse then navigate to the location where you saved the exported the rule project and select the file, as shown in Figure 8.
  • Select the project that will be imported, then click Finish.
Figure 8: Select archive file to import
  • The imported rule project file consists of the following rule artifacts, see Figure 9.
Figure 9: Imported Rule Artifacts
Figure 10: IBM BAW Decisions transformed into IBM ODM Rule Artifacts

After exporting the action rule and decision table and importing them into Rule Designer, the ODM Developer can now develop and update the rule artifacts depending on the user requirements and deploy them on a Rule Execution Server (RES).

Retrieve the Hosted Transparent Decision Service in ODM Rule Execution Server

You can now retrieve the Hosted Transparent Decision Service (HTDS) once you deployed the decision service to the Rule Execution Server (RES). A hosted transparent decision service (HTDS) is an execution component linked to a ruleset path. Using HTDS, you can invoke a deployed ruleset as a web service (WSDL) or REST API. You can generate OpenAPI representations for executing decision services. OpenAPI is a standardized version of the Swagger specification that provides a language-independent way to present REST APIs.

NOTE: You cannot generate an OpenAPI specification if the ruleset uses an XML Schema Definition (XSD) as its execution object model (XOM) instead, use a web service WSDL specification and call it from IBM BAW as a web service.

This section shows you the procedure to download the OpenAPI specification for the service that you will use to discover the IBM ODM decision service as an external REST service. For this example, I use the ‘Customer Loyalty Program’ decision service, which is the enhanced version of the exported rules from the previous section.

  • Login to Rule Execution Server console then navigates to the Ruleset View of the project you want to use, as shown in Figure 11.
  1. Click Explorer where you can browse the deployed RuleApps.
  2. In RuleApps View, click CustomerLoyaltyProgram RuleApp.
  3. In RuleApp View, click the ruleset Cusomer_Loyalty_ProgramRuleset.
  • On the upper right corner of the Ruleset View, click Retrieve HTDS Description File.
Figure 11: Navigating to Retrieve HTDS Description File
  • Select REST for the service protocol type then select OpenAPI — JSON for the Format. Choose the Latest ruleset version and Latest RuleApp version.
Figure 12: Retrieve HTDS Description File
  • Click Download to save the file locally or click View and copy the URL.

The sample OpenAPI Specification file (JSON format)is available in TipsforBAW Toolkit stored in the Github repository.

NOTE: If your ruleset is secured, you must add the security=basic option to the URL so that Business Automation Workflow sends the security credentials to the OpenAPI specification with security definition.

Invoke ODM Decision Service from BAW

Another way to integrate service in IBM Business Automation Workflow (BAW) is by using external services. With external services, you can call service on a system that is external to IBM BAW. It provides an interface where you can discover the service, select operations you want to use, and set a server containing the information required to invoke the service. The types of services available are Java service, a web service, or REST service.

In this section, we will discover a REST service from an OpenAPI Specification (formerly known as Swagger). After downloading the OpenAPI JSON format, we can now invoke the decision service provided by an Operational Decision Manager (ODM) instance. A Decision Service contains one or more rule project that implements the set of business rules and exposed as a web service or REST API. Using ODM Decision Service, you can integrate decision capabilities in Business Automation Workflow (BAW).

The example uses the enhanced Customer Loyalty Program from in the previous article, IBM Business Automation Workflow Implementing Decision Tasks. There are two steps to complete in discovering and using the ODM Decision Service in your workflow application.

  1. Create an External Service to Discover ODM Decision Service
  2. Use the External Service in a Service Flow

Best Practice: ODM Integration should be created in a toolkit so that the decision service is reusable by multiple applications. If you created the integration within the process application, then it will only be used within that process application.

The example is available in the ODM Integration Toolkit stored in the GitHub repository.

Step 1: Create an External Service to Discover ODM Decision Service

  • In the ODM Integration Toolkit navigator, go to Services and then click the plus icon (+) to create a new External Service, as shown in Figure 13.
Figure 13: Services > External Service
  • In the New External Service window, select Java, REST or Web service and then click Next, see Figure 14.
Figure 14: New External Service
  • Select a method to discover your decision service from the following:
  1. REST service from a local file — select an OpenAPI (Swagger) file on your local file system.
  2. REST service from URL — enter the URL of the OpenAPI (Swagger) file.
  3. Web service from Web Service Server — select the server you created for the web service.
  4. Web service from URL — enter the URL of the web service definition language (WSDL) file.
  5. Java service from Server File — select the Java archive (jar) file in the server file.

Since we downloaded an OpenAPI Specification (Swagger) file in the previous section, we will select REST service from the local file and then browse to select the OpenAPI (Swagger) file on your local file system as shown in Figure 15.

Figure 15: Discover Service via REST service from local file
  • In the list of discovered operation/s, select the operation/s you want to include in the external service and then click Next, see Figure 16.
Figure 16: List of Discovered Operations
  • Set the server that contains the properties used to invoke the REST service. Select Create a new server and click Finish, see Figure 17.
Figure 17: Create New Server
  • Once done creating the external service, check the generated artifacts: several business objects and an external service, as shown in Figure 18.
Figure 18: Customer Loyalty Program External Service
  • To verify the configured server, go to Toolkit Settings > Server and check the server details, see Figure 19.
Figure 19: Server Details

Reminder: From the Servers tab, you can add server configurations for Development, Test, Staging, and Production environments so you can connect to the ODM Rule Execution Server instance of the respective environments. Click the plus icon (+) to add a new server configuration, see Figure 20.

Figure 20: Add Server Configurations

Now, we will define BAW services to use ODM Decision Service integration.

Step 2: Use the External Service in a Service Flow

  • In the ODM Integration Toolkit navigator, go to Services and then click the plus icon (+) to create a new Service Flow, as shown in Figure 21.
Figure 21: Services > Service Flow
  • Enter the name of the service and click Finish, see Figure 22.
Figure 22: Create Service Flow
  • Drag into the diagram the created external service and change the name of the service task, as shown in Figure 23.
Figure 23: Add External Service in the Service Flow
  • Set the Implementation by clicking Validate and Determine Rewards service task and under Properties, click Implementation. Select the operation using the dropdown, see Figure 24.
Figure 24: Service Operation
  • Set the Data Mapping of Validate and Determine Rewards. Under Properties > Data Mapping, set the input and output mapping using the auto-map, as shown in Figure 25. It will create private variables for input and output.
Figure 25: Data Mapping
  • Check the created private variables in the Variables tab and expand each variable. The Request variable has two parameters that the ODM Decision Service needs as input, see Figure 26.
Figure 26: Service Variables

NOTE: DecisionID parameter is optional which can be used for tracking purposes. Rule Execution Server generates a unique ID when the ID is not specified. DecisionID is used to identify the transparent decision service that your request defines. If you want to provide a DecisionID, make sure that the ID is unique to avoid conflicts with the element/s implemented in Rule Execution Server.

  • Define input and output variables for Validate and Determine Rewards ODM service flow to be able to invoke the service, see Figure 27. Your input and output variables will depend on the Request and Response of your decision service operation.
Figure 27: Input and Output Variables
  • Map the input and output variables to the Request that used to call the actual ODM service. Add Server Script components to the diagram and then wire them all together, as shown in Figure 28. Set Data script component will set the input variable to the Request, while the Get Data script component will set the Response to the output variable.
Figure 28: Server Script Components

Once done creating the service flow, take a snapshot of your toolkit and then add the toolkit to your process application so you can invoke this service. Now, let’s run our sample implementation by opening the Using ODM Decision Service Example CSHS in TipsForBAW Toolkit.

Before you test the example, make sure that the Customer Loyalty Program RuleApp is deployed in ODM Rule Execution Server. The sample RuleApp is also available in TipsforBAW Toolkit stored in the GitHub repository.

In the Customer Information, enter the Amount Spent in the last two years and click Validate. It should display the corresponding Discount, Loyalty Type, and Additional Rewards Offer based on the rule definitions, see Figure 29.

Figure 29: Using ODM Decision Service Example

Summary

This article has explored the ways to optimize business activity using Business Automation Workflow (BAW) and Operational Decision Manager (ODM) and demonstrated how to externalize rules and manage them in IBM ODM. The following are the criteria to consider using IBM ODM as part of your IBM BAW solution:

  • Complexity — Since IBM BAW based rules are better at handling simple rules, IBM ODM provides the rule orchestrations, which gives a robust set of capabilities to design and deploy a complete decision management solution.
  • Agility and Flexibility — This benefits the business by managing decision services separate from the workflow development that allows the business to change the rules without changing your process application and codes and enables the business to deal with the changing business needs.
  • Reusability and Consistency — Using ODM decision services, clients can maintain the rules as a shared component that ensures all applications and platforms implementing decisions use the same set of rules.
  • Business and IT Collaboration — With ODM decision services, business users and IT teams can work together on defining and managing the lifecycle of rules. It allows business users to access, review, and update rules. At the same time, the IT team can be advisors to the business users to ensure the correctness of the rules and can support them on rule governance for the decision operations.

--

--

Diorella Mari Tom
IBM Digital Business Automation Tips and Assets

Diorella works for IBM Solutions Delivery Inc., Philippines, part of the IBM Expert Labs team, with more than 10 years of experience in application development.