Programming Tutorials Browser Tutorials Articles Struts Tutorials Hibernate Tutorials

Search: 

  Tutorial: Business process automation made easy with Java, Part 2

Business process automation made easy with Java, Part 2

Tutorial Details:

Business process automation made easy with Java, Part 2
Business process automation made easy with Java, Part 2
By: By Ahmed Abulsorour and Siva Visveswaran
Design options for rule engine integration
he key benefits of abstracting a rule engine tier from the business object layer are: independent rules maintenance by business users, rules reuse across business objects, and reuse across multiple business contexts by multiple systems. This abstraction is a two-step process that involves:
Integrating the external engine with a business tier
Selecting the appropriate deployment method and communication protocols between them
In Part 1 , we looked at the first step. In this article, we study the second step. We present different methods for rule engine deployment (e.g., stateful versus stateless) and determine the best options for specific situations. In Part 1, we introduced the Java Rule Engine API (Java Specification Request (JSR) 94) that provides a uniform mechanism to access rule engine services. Now we present emerging data interchange standards such as the Simple Rule Markup Language (SRML) that allow vendor independence in rules development.
Read the whole series, "Business Process Automation Made Easy with Java:"
Part 1: Implement business rule engines in a J2EE enterprise
Part 2: Design options for rule engine integration
Rule engine integration design options
In this section, we discuss two main options to integrate a rule engine product with a Model-View-Controller (MVC)-based J2EE (Java 2 Platform, Enterprise Edition) Web application. The integration options are based on the engine's invocation mechanism?synchronous or asynchronous. The view's main requirement is synchronization with the model so that data displayed to the user is up to date. Based on the Observer pattern, the model acts as the subject, and the view acts as the observer. Synchronization can be achieved by using a push mechanism, where the view listens for change notification in the model, or a pull mechanism, where the view calls the model to get updated data whenever required, as in a Struts framework.
Figure 1 shows the proposed design for the two integration options. The integration tier is abstracted in this figure to the rule engine controller, and the adapter as explained in Part 1. The pattern's main advantage is loose coupling between the application modules and the rule engine technology used in the back end.
Figure 1. Rule engine integration architecture. Click on thumbnail to view full-size image.
Synchronous invocations
As explained earlier, using the suggested MVC design implies synchronous event execution from the Web tier. As shown in Figure 1, the EJBAction component implements the business logic that may or may not require rules execution. Therefore, in case the need for rules execution arises, EJBAction invokes the RulesController for that purpose. As a result of invoking the RulesController , a rule session object is created and initialized with the required objects (facts) from the model that are needed by the rules set to execute. The initialization objects are obtained by calling the corresponding EJBs (business components) and usually represent a snapshot of the data each EJB represents at the time of invocation. The session object is sent to the rules adapter that abstracts the proprietary Java Rule Engine API from the controller implementation. The adapter extracts the facts from the session, initializes the rule engine with them, then loads the requested rules set from a cache (compiled rules set), and fires the rules.
As a result of firing rules, more facts may be created, and some facts may be altered. The adapter extracts the resulting facts from the rule engine's working memory and puts them back into the session object. The session object returns to the RulesController . The RulesController extracts the facts from the session as a result of rules execution, and then attempts to either update the model components (EJBs) with the altered facts or sends the results back to the Web tier so they can display on the screen as a side effect of rules execution. The decision is based solely on the nature of rules and the application's business logic. For example, server-side validation rules cause the controller to return the results of rules execution as a validation message to the Web tier; meanwhile, action-based rules may cause the controller to update the data in one or more EJBs.
Asynchronous invocations
Some applications require rule engine invocation in asynchronous mode. As shown in the previous section, given the events cycle explained in MVC, asynchronous behavior is not achieved with that design. Messaging middleware, such as Java Message Service (JMS), is recommended for asynchronous rule engine invocation. As shown in Figure 1, the gray components allow the application to communicate asynchronously with the rule engine.
Two JMS queues (or one queue and one topic) can be used as rule engine input queue and rule engine output queue, respectively. The EJBAction detects the need to invoke the rule engine service in an asynchronous fashion and consequently invokes the RequestSender component to accomplish that task. The RequestSender maps the data sent by the EJBAction (mostly optional fact objects and a hint about the rule set to be executed) into an XML message that represents the request to the rule engine. The RequestSender can use a protocol repository to create the XML message; it then puts the message on the rule engine input queue.
A message bean ( RulesMBean ) listens to the request on the input queue and gets triggered when a request arrives. The RulesMBean extracts the optional facts and the mandatory rules set (or business rule name), and, based on this information, decides which method to call in the rule engine controller. The controller invokes the adapter as mentioned previously and updates the model as a result of firing rules. The controller might decide to send back a response to the message originator; in that case, it would create a response XML message using the ResponseSender component. The ResponseSender puts a message on the rule engine output queue or topic. The ApplicationMBean that listens on the output queue can pick up the response message. The following code snippets illustrate this idea:
...
public class RulesEngineRequest
{
private Document request;
private String rulesetName;
private HashMap properties;
private String id;
private String replyTo;
public RulesEngineRequest(String xmlString) throws RulesEngineException
{
try
{
request=DocumentBuilder.createDocument();
...
...
request.parse(xmlString);
rulesetName=null;
properties=null;
id=null;
replyTo=null;
} catch (Exception ex)
{
throw new RulesEngineException("Could not parse the request due to the following exception:\n"+ex);
}
}
...
...
public class RulesEngineResponse
{
private Document response;
public RulesEngineResponse(IDocument doc) throws RulesEngineException
{
response=doc;
try
{
response.addElement("/rules-response", "result-descriptor");
response.addElement("/rules-response/result-descriptor", "outcomes");
} catch(Exception ex)
{
throw new RulesEngineException("Could not create RulesEngineResponse due to the following exception:\n"+ex);
}
}
...
...
public class RulesMBean implements MessageDrivenBean, MessageListener
{
...
public void onMessage(Message msg)
{
TextMessage tm = (TextMessage) msg;
try
{
String text = tm.getText();
RulesEngineRequest request=new RulesEngineRequest(text);
String rulesetName=request.getRulesetName();
Map properties=request.getProperties();
...
RulesEngineControllerLocal rulesEngineController=CoreEJBUtil.getRulesEngineControllerLocalHome().create(new HashMap());
rulesEngineController.addFacts(factsList);
rulesEngineController.fireRules(rulesetName);
factsList=rulesEngineController.getFacts();
...
Note: Download the complete source code that accompanies this article.
Applying the options
Clearly, business requirements mostly drive invocation method selection; but, from a performance perspective, asynchronous invocation can be more desirable because backend resources can serve it better, and the client can do other tasks during processing. In a credit card authorization scenario, for example, asynchronous invocation might not be an option, but it might be an option for risk underwriting situations. However, the RulesController has no knowledge about the invocation method, and therefore, the same rule set may be fired in two different ways depending on the scenario.
Design considerations
In this section, we discuss some design considerations regarding the suggested integration design.
Data synchronization
One major performance issue with the suggested integration design is the need to synchronize data back to the model components after a rules engine invocation. In a J2EE-distributed environment, the model components can deploy in more than one application server and usually on different JVMs. There is no guarantee that the update process for model components (explained earlier) is done locally, but it usually happens over the network using RMI-IIOP (Remote Method Invocation-Internet Inter-ORB Protocol). Two main approaches overcome this problem:
The first option is to collocate the business components most affected by the rule engine rules-firing on the same JVM as the rule engine. The use of EJB 2.0 local interfaces is most efficient for that purpose. The other approach is to optimize the update cycle by designing the fact objects to implement a Dirty Marker pattern that allows the controller to figure out which object has been altered by the rule engine and which has not. The controller inspects the dirty indicator in all the objects and sends the dirty ones to the corresponding EJB to be stored. It is also worth noting that some rule engine products can deal with EJBs directly as facts in th


 

Read Tutorial at: Click here to view the tutorial

Rate Tutorial:
Business process automation made easy with Java, Part 2

View Tutorial:
Business process automation made easy with Java, Part 2

Related Tutorials:

Displaying 1 - 50 of about 3928 Related Tutorials.

Business Intelligence
technology and concepts like BI made it easy to access and manage all kinds... inevitable and hence is going to be a major part of in all kinds of business... Business Intelligence    
 
JDO UNPLUGGED - PART 1
Relational Mapping' Technology developed by Java Community Process(JCP), with active...; SPD Oreilly Publication. 2. Java Data Objects (2003)    - Robin M... JDO - Java Data Objects Tutorials, JDO Java Data Object, JDO Tutorial, JDO
 
Open Source Business Model
the viability of open source biotechnology as a business model. The first is made up... Open Source Business Model Open Source Business Model What is the open source business model It is often confusing to people
 
Struts 2 Tutorials for Beginners, Struts 2 Tutorial
Struts 2 Tutorial,Struts2 Examples,Apache Struts 2 Tutorials - Free Java... on Struts 2 framework.    Writing Jsp, Java... part of any web application. With the release of Struts 2, validation are now much
 
Struts 2 Tutorial
Struts 2 Tutorial,Struts2 Examples,Apache Struts 2 Tutorials - Free Java... on Struts 2 framework.    Writing Jsp, Java... part of any web application. With the release of Struts 2, validation are now much
 
Java Interview Questions - Page 2
: 1. The Java Virtual Machine (Java VM) 2. The Java... is the package? Answer: The package is a Java namespace or part of Java... Java Interview Questions,interview questions java Java
 
VOIP for Your Business
that long distance calls are becoming an integral part of business communications... applications or other custom made applications with it. VoIP lends itself to easy... VOIP for Your Business VOIP for Your Business
 
The Future of Business Intelligence
of BI inevitable and hence is going to be a major part of in all kinds of business... The Future of Business Intelligence GPS Capability,GPS Capabilities The Future of Business Intelligence
 
eClarus Business Process Modeler
Eclipse Plugin-Language eClarus Business Process...;     Focus on connecting IT to business requirements... through shared models and artifacts among business analysts and SOA architects
 
Open Source Workflow Engines in Java
server, JBoss said it has acquired the open source Java Business Process... with workflow process constructs that can be built in Java applications. 2. BPEL... Workflow Engines in Java The Open For Business Project: Workflow Engine Guide
 
Business Intelligence Tools
DISCUSSED that Business Intelligence is a process to collect data and extract... Business Intelligence Tools GPS Capability,GPS Capabilities Business Intelligence Tools    
 
Small Business Computer Security, the Basics
system, simply upgrade to service pack 2 and it includes a free and easy to use... Small Business Computer Security, the Basics Small Business Computer Security, the Basics
 
JDO UNPLUGGED - PART II
JDO - Java Data Objects Tutorials, JDO Java Data Object, JDO Tutorial, JDO UNPLUGGED - PART II JDO UNPLUGGED - PART II... www.jcp.org and selecting JSR-12 or can be downloaded from sun java website. Goto
 
Introduction to Maven 2
Introduction to Maven 2 Introduction to Maven 2...;  Maven2 is an Open Source build tool that made... but not all plugins that exists for maven1 are ported yet. Maven 2 is expected
 
Easy Struts
generation. Provide a global view of any Java project with Easy Struts... Easy Struts Easy Struts...;         The Easy Struts project
 
Development Process
Java: Development Process Java: Development Process Software development can be looked at from two perspectives process and product. Process is how you go about writing programs
 
Java Struts 2 Programmer
Java Struts 2 Programmer Java Struts 2 Programmer...;   Position Vacant: Java Struts 2 Programmer ...; Reference ID: Java Struts 2 Programmer   
 
Business Intelligence in Insurance
in the business process and should be done with proper calculation and analysis by using... intelligence is now one of the integral part of the decision making process. After... Business Intelligence in Insurance GPS Capability,GPS Capabilities
 
Struts 2 datetimepicker Example
toolkit for creating date picker. In Struts 2 its very easy to create date time... 2 date picker is actually Dojo widget, that makes it easy to select a date... Struts 2 datetimepicker,Struts 2 datetimepicker Example,Datetimepicker Struts
 
Open Source Java
extension to the Java programming language, Java platform compatible and easy... that Java 2 Standard Edition, may soon be set free of Sun Microsystems' notoriously..., the group said Apache could sponsor a rebuild of the Java 2, Standard Edition
 
Web Services Tutorials and Links
: The Java XML Pack is the first certified release of Web services tools for J2EE (Java 2... for application to application communication. The programmatic interfaces made... format bindings.     Java Web services
 
History of Business Intelligence
of new technology and concepts like BI made it easy to access and manage all... History of Business Intelligence GPS Capability,GPS Capabilities History of Business Intelligence  
 
Calculate process time in Java
Calculate process time in Java Calculate process time in Java          ... the process time of the completion of the operation through the Java program
 
Free Java Books
Yourself Java 2 in 24 Hours As the author of computer books, I spend a lot... multitier enterprise applications with the Java TM 2 Platform, Enterprise..., are part of the successful Java BluePrints program created by Sun Microsystems
 
Struts 2 Training
Struts 2 Training, Training for developing applications with Struts 2 Struts 2 Training       ...;       The Struts 2 Training for developing
 
Open Source web Templates
Open Source Web Templates A web site template is a pre-made website with essentially no content. This makes it easy for you to have...;   Open Source Template Engines in Java Velocity is a Java-based
 
Java Server Faces (JSF) Tutorial
Overview  JSF was developed by Java Community Process(JCP... standard framework, developed through Java Community Process (JCP), that makes it easy to build user interfaces for java web applications by assembling reusable
 
J2EE Interview Questions -2
(including databases). JCA was developed under the Java Community Process as JSR... Questions -2           ...: JTA stands for Java Transaction API and JTS stands for Java Transaction Service
 
Business Intelligence in Healthcare
Business Intelligence in Healthcare...; TO MAKE A PROFIT DRIVEN BUSINESS decision, every company depends.... Business Intelligence (BI) is solely offers solution to data warehousing and data
 
Struts 2 Login Application
and easy steps to develop Login page in the using Struts 2 framework. Develop... Struts 2 Login,Struts 2 Login Application,Struts 2 Application Struts 2 Login Application      
 
Struts 2 Tags Examples
. Struts 2 tags provides easy to use custom tags to help the developers to make GUI for their struts 2 based applications. In Struts 2 there are many easy to use tags and the learning process for these tags are also easy.  There are two
 
Java Programming Books
; Sams Teach Yourself Java 2 in 24 Hours..., and the accompanying Java Pet Store sample application, are part of the successful Java BluePrints... been designed through an open process, the Java Community Process (JCP). This open
 
ILOG Business Rule Studio
ILOG Business Rule Studio ILOG Business Rule Studio...-editing and debugging of Java code and rules. Rule Studio supports deploying... with business rule authors through integration with Rule Team Server. In addition
 
Maven 2: Features
the complete state of a project in the shortest time by using easy build process, uniform... like: It makes the build process easy Provides a uniform building system... Maven 2: Features Maven 2: Features
 
Struts 2 Features
to the action class.  Strut 2 actions are Spring friendly and so easy to Spring... Struts 2 Features Struts 2 Features   ... platform requirements are Servlet API 2.4, JSP API 2.0 and Java 5.  Some
 
Why Struts 2
. Annotations introduced : Applications in struts 2 can use Java 5 annotations.... Easy Spring integration - Struts 2 Actions are Spring-aware. Just need to add Spring beans! Easy plugins - Struts 2 extensions can
 
Why Struts 2
. Annotations introduced : Applications in struts 2 can use Java 5 annotations.... Easy Spring integration - Struts 2 Actions are Spring-aware. Just need to add Spring beans! Easy plugins - Struts 2 extensions can
 
Wi-Fi as a part of LBS
Wi-Fi as a part of LBS Wi-Fi as a part of LBS            ... direction in cities, to locate any particular business points, to track stolen
 
Easy Eclipse Plugin
Easy Eclipse Plugin Easy Eclipse Plugin..., so it may easier to install the Server Java distribution. Eclipse J2EE tools..., with support of Enterprise Java Beans 3.0 and Aspect-Oriented Programming  Know
 
Java Util Examples List
and classes for easy manipulation of in-memory data. The java util package...;       Calculate process time in Java...;  Decreasing process time by caching through the Hash Table in Java
 
Java: String Exercise 2
Java: String Exercise 2 Java: String Exercise 2 Name ______________________ Assume the following.... 1__________h.length() 2__________h.substring(1) 3__________h.toUpperCase() 4
 
Maven 2 Eclipse Plug-in
Maven 2 Eclipse Plug-in Maven 2 Eclipse Plug... Integration makes the development, testing, packaging and deployment process easy and fast. Maven Integration for Eclipse provides a tight integration for Maven
 
Struts 2 - History of Struts 2
Struts 2 History Struts 2 History   ... is an open-source framework that is used for developing Java web application... and Servlet based on HTML formats and Java code. Strut1 with all standard Java
 
Developing JSP, Java and Configuration for Hello World Application
Writing JSP, Java and Configuration for Hello World Application,Struts 2 Hello World Writing JSP, Java and Configuration for Hello... the output. In the struts 2 framework Actions are used to process
 
Struts 2 Architecture - Detail information on Struts 2 Architecture
Struts 2 Architecture,Struts Architecture Struts 2...;   Struts and webwork has joined together to develop the Struts 2 Framework. Struts 2 Framework is very extensible and elegant for the development
 
Struts 2 Validation Example
application java script can be added to the jsp page or in action class, but Struts 2... Struts 2 Validation,Struts 2 Validation Example Struts 2 Validation Example         
 
SME Server 7.0 Pre 2 has been released now
a solid, easy-to-use server for their small-business customers. In July 2001, e-smith... SME Server 7.0 Pre 2 has been released now SME Server 7.0 Pre 2 has been released now SME Server 7.0 pre-release 2
 
How Struts Works
; Model : The model is basically a business logic part which takes the response...;       The basic purpose of the Java Servlets in struts is to handle requests made by the client or by web browsers
 
JSF Tutorial for Beginners
;    JAVA SERVER FACES ( not to be confused with JSP..JAVA SERVER PAGES), is the latest technolgy from JCP(Java Community Process). It is ...; illustration. ---------      JAVA SERVER FACES is 
 
Decreasing process time by caching through the Hash Table in Java
Decreasing process time by caching through the Hash Table in Java Decreasing process time by caching through the Hash Table in Java...;   This section illustrates you how to improve the process time
 
Site navigation
 

 

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2006. All rights reserved.