Vous êtes sur la page 1sur 14

Diversify your IBM ODM application with Bluemix and

the Business Rules service, Part 1


Understand the differences and set up your environment
U. Siddiqui (usiddiqu@us.ibm.com)
IBM Software Engineer
IBM

09 December 2015

The Business Rules service on IBM Bluemix minimizes your code changes by keeping
business logic separate from application logic, providing the capability for decision
management on Bluemix. This tutorial provides a brief overview of the service and details
about how to diversify existing on-premises IBM Operational Decision Management (ODM)
applications to also use the Business Rules service.
Learn how to diversify your existing IBM Operational Decision Management (ODM) applications
to also use the Business Rules service on IBM Bluemix. After an introduction to IBM ODM and the
Business Rules service and details about how they differ, you walk through deploying and running
a subset of your rules on the Business Rules service. In addition to the on-premises IBM ODM
installation, you can take advantage of the pay-as-a-service solution that is provided on Bluemix.
This content is part of the IBM Business Process Management Journal.
This tutorial is the first in the Diversify your IBM ODM application with Bluemix and the Business
Rules service series.

Part 1 of this series provides a brief overview of the


Business Rules service and details about how to diversify
existing on-premises IBM ODM applications to also use the
Business Rules service.
IBM ODM enables decision management in enterprises through business rules. The two
main components of IBM ODM are IBM Decision Center and IBM Decision Server. With these
components, you can manage and run business rules to make decisions faster. Also, you can
change rules faster, outside of the normal software development cycle. Business rules and the
associated business object model are initially created and edited in the Eclipse-based Rule
Designer by developers, and later created and edited in the Decision Center web console by
Copyright IBM Corporation 2015
Diversify your IBM ODM application with Bluemix and the
Business Rules service, Part 1

Trademarks
Page 1 of 14

developerWorks

ibm.com/developerWorks/

business users. The rules are stored in a repository and are deployed to the Decision Server as
RuleApps for testing and execution. The following illustration shows the IBM ODM components
and how they manage business rules.

IBM Bluemix is an open-standards cloud platform that provides mobile and web developers access
to IBM software for integration, security, transaction, and other key functions, and to software from
business partners. A platform as a service cloud offering built on the Cloud Foundry open source
technology, Bluemix is a place where you can deploy your apps, giving you immediate access to
services and expediting the delivery of a web or mobile application by removing steps for service
installation, infrastructure management, and maintenance. The following illustration shows the
Bluemix architecture.

Diversify your IBM ODM application with Bluemix and the


Business Rules service, Part 1

Page 2 of 14

ibm.com/developerWorks/

developerWorks

The Business Rules service in Bluemix minimizes your code changes by keeping business logic
separate from application logic. It captures business logic in the form of business rules, which
can be run on the cloud. The following image shows the Business Rules service components and
how they manage business rules. You first develop and test the rules and the associated business
object model in the Rule Designer plug-in on Eclipse. Then, you create a Business Rules service
instance by using the Bluemix user interface. You deploy the rules in archives that are known as
RuleApps from the Rule Designer to the Business Rules service instance.
The following illustration shows the business rules service components.

Diversify your IBM ODM application with Bluemix and the


Business Rules service, Part 1

Page 3 of 14

developerWorks

ibm.com/developerWorks/

Bluemix is a pay-as-a-service solution, intended to remove steps for managing and maintaining
service installation and infrastructure. The Business Rules service eases the deployment and
execution of rules by removing the need to install and maintain the IBM ODM components on
an on-premises application server instance. Also, you don't need to install and maintain an onpremises database to persist rule data.

What you need to build your application


Familiarity with IBM ODM development
An IBM Bluemix account
Familiarity with web services, REST API, JSON, SOAP, and XML

Step 1. Understand the differences between IBM ODM and the


Business Rules service on Bluemix
The Business Rules service is different from IBM ODM in the following ways:
Unlike IBM ODM, you do not need to install the Rule Execution Server on an WebSphere
Application Server instance or another application server. Instead, each Business Rules
service instance has a Rule Execution Server instance that provides the runtime environment
for running and monitoring RuleApps.
The Execution Unit (XU) is part of the Rule Execution Server and handles the actual rules
execution and manages resources. You do not need to explicitly install the XU on an
application server like you must do when you use IBM ODM.
You can manage the Rule Execution Server for the service through the Rule Execution Server
console. However, you can't configure the XU for the service, like you can with an IBM ODM
installation.
The rule data is also persisted by the service, and you don't need to set up a database to
persist your rule data like you must do in IBM ODM.
When a RuleApp is deployed to the Business Rules service instance, each ruleset in the
RuleApp is exposed as a web service. This web service can either be started through
REST API or SOAP. This feature is equivalent to using the REST transparent decision
service provided by the IBM ODM Decision Server or the hosted transparent decision
service (HTDS) provided by the IBM ODM Decision Server. See Executing rules by
using the REST service and Hosted transparent decision services in the IBM ODM
documentation. HTDS, as shown in the following illustration, is an execution component

Diversify your IBM ODM application with Bluemix and the


Business Rules service, Part 1

Page 4 of 14

ibm.com/developerWorks/

developerWorks

that is linked to a ruleset path through a Java Management Extensions management bean.

However, IBM ODM also provides other options to run rules (Java Objects, Enterprise
JavaBeans, and Message-Driven beans) that are not available through the Business Rules
service on Bluemix. See Developing client applications in the IBM ODM documentation.
Interceptors are not supported by the Business Rules service.
In IBM ODM, the Rule Execution Server console provides a Testing feature to test your
ruleset with sample data. This feature is not supported by the Business Rules service on
Bluemix. However, you can test your ruleset payload from the Bluemix console, without
logging into the Rule Execution Server console. See Step 6.
In IBM ODM, you can configure rule tracing by using the ruleset properties
ruleset.trace.enabled, ruleset.sequential.trace.enabled, and filters. See Setting up
ruleset execution traces and IlrTraceFilter in the IBM ODM documentation. In contrast, rule
tracing is disabled by default in the Business Rules service. However, you can configure the
payload to enable tracing, as described in Part 2, Step 1.
In IBM ODM, you can monitor ruleset execution with the Decision Warehouse, which is a tool
for the Rule Execution Server console that stores rule execution traces in a database. The
Business Rules service does not support the use of the Decision Warehouse.
The use of Decision Validation Services (DVS) is not supported by the Business Rules service
on Bluemix. However, you can use your existing IBM ODM test environment to conduct DVS
tests on the rulesets if needed before you deploy them to the Business Rules service on
Bluemix for production.
There is no Decision Center associated with the Business Rules service on Bluemix.

Given these differences, rulesets that are prime candidates for using the Business Rules service
on Bluemix have the following characteristics:
Performance: Rulesets that are already hosted through REST transparent decision services
or SOAP hosted transparent decision services, or can be started as a web service without
negatively affecting the user or application in the transition to web services.
Rulesets that depend on the high performance that is delivered by a Java SE implementation,
for example, would not be viable candidates. To determine whether your ruleset is a good
candidate to be hosted by the Business Rules service on Bluemix, see Executing rulesets as
a web service in the Deployment architecture IBM ODM documentation, and Performance
Diversify your IBM ODM application with Bluemix and the
Business Rules service, Part 1

Page 5 of 14

developerWorks

ibm.com/developerWorks/

demands and application types in the Overview: What affects the performance of a Decision
Server application IBM ODM documentation.
Customization: Rulesets that do not require configuration at the XU level (for example, XU
connection pools or the asynchronousRulesetParsing, compiledArchivesCacheProperties XU
properties), or depend on the use of interceptors.
Maintenance: Rulesets that are usually developed, deployed, and maintained by developers,
and are not edited or deployed by business users (or infrequently).
In addition, the Business Rules service can be used for the following purposes:
You can quickly and easily validate any ruleset in development, and test the client application,
without needing to configure application servers for deployment and maintenance of the
Decision Server.
You can free up precious CPU, memory, and database resources (used by the on-premises
IBM ODM installation) to allocate to needier resource-intensive applications.
Depending on how your current IBM ODM application is structured, you might need to make
changes before your existing rules can be deployed to the Business Rules service on Bluemix and
started as web services. Continue reading to learn how to use the Business Rules service and how
to configure your existing IBM ODM application to use the service. Part 2 discusses the tracing
and performance settings applicable to the Business Rules service.

Step 2. Design your rules


You can use your installed IBM ODM Rule Designer, or install the Rule Designer plug-in for
Eclipse, as described in the Installing Rule Designer documentation. The plug-in is similar to the
IBM ODM Rule Designer. You can use it to either design a new set of rules and object model, or
use projects from your existing IBM ODM rules applications.

Step 3. Configure the execution object model (XOM)


As mentioned earlier, the Rule Execution Server for the Business Rules service uses transparent
decision services to expose a deployed ruleset with an XML or a Java XOM as a web service. The
Web Application Description Language (WADL) of a REST transparent decision service or the
Web Services Description Language (WSDL) of a SOAP HTDS is generated for each deployed
ruleset archive. Traditionally, only XML XOMs were used with HTDS. However, starting with IBM
ODM V8.x, a Java XOM also can be used. Configure your XML or Java XOM so it can be used
with the transparent decision service.
If you use an XML XOM, apply the following configurations:
1. Associate the XML schema files with a package name, because the classes that are
generated in the XOM from the schema files are defined under that package name. These
classes are added to the generated WADL or WSDL file for the ruleset. You can also use the
Rule Designer to control which dependencies are included in the ruleset archive. See the
XML XOM section in the Hosted transparent decision services IBM ODM documentation.
Diversify your IBM ODM application with Bluemix and the
Business Rules service, Part 1

Page 6 of 14

ibm.com/developerWorks/

developerWorks

2. Configure the size of the execution pool of XML document drivers, which is set by default to
1, through the xmlDocumentDriverPool.maxSize ruleset property. This default setting might
cause a performance bottleneck if several clients run a ruleset that is exposed as a web
service concurrently. Increase the value to the number of concurrent executions of the ruleset.
For example, set it to 5, if you have five concurrent clients.
If you use a Java XOM, apply the following guidelines:
With a Java XOM, a schema is generated through the default JAXB generation and added to
the WADL or WSDL file. If you want a private attribute of a class to be part of the generated
WADL or WSDL file, ensure that the Java class has the corresponding public getter and setter
methods for that attribute. Alternatively, you can add JAXB annotations to the attribute in the
Java class:
XmlElement(name="requestAmount")
@ private double requestAmount;

Use JAXB notations to specify the namespace for the generated schema, otherwise the
default namespace will be used:
@XmlRootElement(name="my-loan", namespace="http://www.acme.com/loan")
public class MyLoan {
...
}

See the Java XOM section in the Hosted transparent decision services IBM ODM
documentation.
When you use a Java XOM with the Business Rules service, JAXB is used to instantiate
objects during rule execution. Define a default constructor for the Java classes that will be
used by the rules, since by default, JAXB uses the default constructor for instantiating objects.
This default constructor should also be made visible in the Business Object Model (BOM). If
your current application uses a non-default constructor that completes certain calculations
before it instantiates an object, modify your code so that these calculations are completed
by another method that can be started after the default constructor is called. You can start
this method on the objects in the initial actions of the ruleflow, for example. Otherwise, these
calculations will not be started when rules are started through a web service, because the
default constructor is used.
If you bundle your XOM within your application or if you use the managed Java XOM feature,
package only the JAR files that contain the classes that are directly called by the XOM.

Step 4. Create a Business Rules service instance


1. Log in to the Bluemix console with your Bluemix account, and create a space called dev, for
example. See the Managing your organization section in the Managing your account Bluemix
documentation.
2. Use the Bluemix user interface to create a Business Rules service instance, as
described in the documentation at Creating a Business Rules service instance. The

Diversify your IBM ODM application with Bluemix and the


Business Rules service, Part 1

Page 7 of 14

developerWorks

ibm.com/developerWorks/

following screen capture shows the Business Rules service in the Bluemix catalog.

3. Specify the dev space when you create the instance. You can leave the service
unbound for now, by leaving the App field blank, as shown in the following screen

capture.
4. You can now manage the Business Rules service instance Rule Execution Server
with the web-based console, which is a JMX Beans-based, graphical web interface for
managing the RuleApps (the same as in IBM ODM). Retrieve the credentials to log in to
the Rule Execution Server console from the Connection Settings tab of the Business
Rules service instance. To connect to the Rule Execution Server console, click the

Diversify your IBM ODM application with Bluemix and the


Business Rules service, Part 1

Page 8 of 14

ibm.com/developerWorks/

developerWorks

Open Console link and log in using the credentials, as shown in the following screen

capture, .

Step 5. Deploy your rules


The rules are deployed in archives, known as RuleApps, from the Rule Designer to the Rule
Execution Server that is associated with the Business Rules service instance. As in IBM ODM,
you first create a RuleApp project that is associated with your rules project, and then deploy the
RuleApp to the Rule Execution Server of the Business Rules service instance.
1. Create a Rule Execution Server configuration for the Business Rules service instance.
Retrieve the information from the Connection Settings tab of the Business Rules service
instance (the previous screen capture).
2. Create a RuleApp project that is associated with the rule project. Right-click the RuleApp
project, click RuleApp > Deploy, and select the deployment type. If you do not want to
keep updating the RuleApp or the ruleset versions referenced in the client application,
select Replace RuleApp version. Then, specify the Rule Execution Server configuration
for the Business Rules Service instance. Make sure that Deploy XOM of rule projects and
archives that are contained in the RuleApp is selected when you deploy the RuleApp.
If you work with the res-deploy Ant task to deploy RuleApps in IBM ODM, you also can
use it deploy RuleApps in the Business Rules service on Bluemix. Specify the hostname,
portnumber, secured, and password attributes, like the following example:
<!-- Deploy the ruleapp to the Business Rules service -->
<target name="deploy-ruleapp">
<res-deploy hostname="brsv2-12345678.ng.bluemix.net" mergingpolicy="ADD_AT_END_MERGING_POLICY"
portnumber="443" secured="true" userid="resAdmin" password="xxxxxxxxxxxx" file="myruleapp.jar" />
</target>

Make sure that the XOM is added to the RuleApp.


Diversify your IBM ODM application with Bluemix and the
Business Rules service, Part 1

Page 9 of 14

developerWorks

ibm.com/developerWorks/

If you neglected to deploy the XOM with the RuleApp, or if the XOM has been updated,
you can deploy the XOM to the Business Rules service instance from the Rule Designer.
Right-click the rule project name and then select Rule Execution Server > Deploy XOM.
Alternatively, you can deploy it using the res-deploy-xom Ant task. In the Rule Execution
Server console, configure the ruleset to use the most recent Managed XOM resource version.
3. Select your Business Rules service instance on the Bluemix console, and go
to the Decision Services tab to see your deployed RuleApps and rulesets in
the Bluemix console. Click Refresh if needed, as shown in the following screen

capture.
4. Click the ruleset name to go to the Details page, as shown in the following screen
capture. Choose the relevant tab (JSON, XML, or SOAP) for your use case. Click
WADL (or WSDL if you are using SOAP) to ensure that the description language
is correctly generated. If you see errors, revisit Step 3 to properly configure the

XOM.

Step 6. Test the ruleset payload


In IBM ODM, the Rule Execution Server console provides a testing feature to test your ruleset
with sample data. This feature is not supported by the Business Rules service on Bluemix.
Diversify your IBM ODM application with Bluemix and the
Business Rules service, Part 1

Page 10 of 14

ibm.com/developerWorks/

developerWorks

However, you can test your ruleset payload from the Bluemix console, without logging in to the
Rule Execution Server console.
Each ruleset can be started as a SOAP/XML, REST/XML, or REST/JSON web service. The
REST service passes incoming data as HTTP content in XML or JSON format. The REST/JSON
invocation protocol supports an execution object model (XOM) based on Java. The Business
Rules service provides a REST service that handles the payload generation through the HTTPS
protocol.
1. From the Ruleset Details page (the previous screen capture), click Back to Decision
Services.
2. To test the ruleset, click the arrow icon next to it. The Test page shows the Decision Request
and the Decision Response, as shown in the following screen capture. Choose the relevant
data format (JSON or XML) and generate the corresponding sample payload under Decision

Request.
3. Populate the generated payload with test data, and click Run Test. The ruleset is run with
test data, with the response from the ruleset execution that is displayed under Decision
Response. See Testing a ruleset in IBM Bluemix documentation.

Step 7. Configure the client application to start the rules


The Business Rules service provides a REST transparent decision service that handles the ruleset
execution through the HTTPS protocol, and a hosted transparent decision service to handle
ruleset execution through SOAP .
Diversify your IBM ODM application with Bluemix and the
Business Rules service, Part 1

Page 11 of 14

developerWorks

ibm.com/developerWorks/

Configure your client application to start rulesets that are hosted on the Business Rules service, by
using the following guidelines:
If your current application relies on the use of rule sessions, JMS messages or SCA services
to start rules, modify it to start your ruleset as a SOAP/XML, REST/XML, or REST/JSON web
service, through a web request. The Samples and Tutorials documentation for the Business
Rules service shows how to use both technologies to start rules.
If you choose to host your client application on Bluemix, bind the service instance to the
client application. In the Bluemix console dashboard, select your app, click Bind a service
to choose the service instance that is created in Step 4. If your client application is external
to Bluemix, use the credentials from the Connection Settings tab (in Step 4) to connect to the
service.
If you use the REST service, generate a JSON or XML payload based on the ruleset
parameters by entering a GET request to specified URIs:
GET ruleset_URL/json
GET ruleset_URL/xml

The ruleset_URL is the URL that you retrieve from the Ruleset Details page in Step 5. You
also can generate an XML or JSON payload from the Decision Services page, as described in
Step 6.
Next, configure your client application to make the execution request by using the POST
method:
POST ruleset_URL

The request body must contain the ruleset input parameters as an XML or JSON payload
(which you generated earlier with the GET requests). Because the REST service uses basic
HTTP authentication, use the provided credentials for the service instance.
If you are using SOAP in your environment, use the URL specified in the SOAP tab of the
Ruleset Details page (in Step 5) to call the ruleset. Specify the input parameters in the XML
format.
The execution response is in the same format as the execution request. Configure your client
application to process the response data.
Configure your application to not depend on the use of interceptors, since they are not
supported by the Business Rules service. Take this approach even if your current IBM ODM
application uses interceptors with transparent decision services.

Conclusion
In this tutorial, you learned how to diversify your existing IBM ODM application to use the Business
Rules service on Bluemix. To learn the tracing and performance configurations for the Business
Rules service, see Part 2.

Acknowledgements
The author would like to thank Alain Robert and Pierre Berlandier for their reviews of this tutorial.
Additional appreciation goes to the IBM ODM and Business Rules service technical resolution
teams, including Level 2 and Level 3 Support teams, and research and development.
Diversify your IBM ODM application with Bluemix and the
Business Rules service, Part 1

Page 12 of 14

ibm.com/developerWorks/

developerWorks

Business Ruleshttps://console.ng.bluemix.net/catalog/business-rules/minimize your code changes


by keeping business logic separate from application logic.
RELATED TOPICS: Learn about IBM Bluemix Get started with Business Rules Read IBM
ODM documentation Consult Stack Overflow

Diversify your IBM ODM application with Bluemix and the


Business Rules service, Part 1

Page 13 of 14

developerWorks

ibm.com/developerWorks/

About the author


U. Siddiqui
U. Siddiqui is a software engineer who has worked closely with IBM Operational
Decision Management customers on technical resolution issues for a number of
years, during which she has gained extensive insight into how enterprise customers
use these products and integrate them into their environments.
Copyright IBM Corporation 2015
(www.ibm.com/legal/copytrade.shtml)
Trademarks
(www.ibm.com/developerworks/ibm/trademarks/)

Diversify your IBM ODM application with Bluemix and the


Business Rules service, Part 1

Page 14 of 14

Vous aimerez peut-être aussi