About Me
Facebook
Facebook
Linked In
Linked In
Twitter
Twitter
YouTube
YouTube
Google +
Google +
Showing posts with label IBM WPS. Show all posts
Showing posts with label IBM WPS. Show all posts

Sunday, March 16, 2014

Developing Business State machine in IBM WPS

Introduction
This article provides an overview of the Business State Machine component and its capabilities and discusses the usage of BPEL processes as an alternative. The series builds a vending machine by using more Business State Machine capabilities. We make our vending machine collect money, introduce actions, and test it using a component test.
Overview
BSM provides support for business items that have a life cycle. These are items that have states that are driven by events, and typically have loop-based logic (returning to previous states). A vending machine can be turned on, collect money, dispense a product, and return change. It follows this loop over and over again until it is turned off. It has other loops as well. For example, the vending machine must ensure that the customer has deposited enough money before the requested product can be dispensed. Furthermore, if applicable, change may need to be returned to the customer.
It is typical for this type of application to be represented using a state machine. A state machine basically consists of states with transitions between them. These transitions can occur in a number of ways. A BSM, like other components in Process Server, is a Service Component Architecture (SCA) component. Its interface is defined using the Web Services Definition Language (WSDL). Any number of WSDLs can be predefined and associated with the BSM as it is developed. And, all of the operations defined in these WSDLs must be used in the BSM. For BSMs, WebSphere Integrated Developer provides a way of graphically developing the BSM. The editor's representation is based on the Unified Modeling Language (UML) definition of state machine modeling and design. We will show how the state machine is represented in the editor as we build and extend the vending machine.
The BSM editor works with an XML representation of the state machine called the State Adaptive Choreography Language (SACL, pronounced sachel). The SACL file is used to generate a Business Process Choreography (BPC) BPEL process. This process is long running so that it manages persistence of the state of the state machine. The fact that a process is generated does not impact the development, debugging, or monitoring of a BSM. However, when administering a BSM either through the BPC Explorer or the BPC Explorer runtime API, the core functionality and interaction with the state machine is represented by a long running BPEL process.
Because BSM generates a BPEL process, this leads to the question of when one approach should be used over the other when designing business applications. At the highest level the processes can be thought of as "verbs" that work with state machines that are "nouns." However, in cases where the state machines are--and will--remain simple, it may be better to use a process. For example, a state machine without any loops (returning to an earlier state), would probably make more sense being developed as a process. However, if there is a lot of looping, the state machine provides a much more natural way to develop, debug, and monitor.
This state machine has three states and two transitions.
InitialState1 state is an initial state that is indicated by the green circle icon. Since this is where the state machine starts, every state machine must have exactly one initial state.
FinalState1 state is a final state that is indicated by the blue circles icon. The state machine ends when it reaches a final state. There can be multiple final states, but since the state machine always ends when reaching a final state, defining multiple final states in a BSM has no effect on the application functionality or logic. Multiple final states would only be used when different entry actions are needed (covered in an upcoming article) or, more often, to make the state machine more readable.
Running state is referred to as a simple state. In this case, the Running state can be entered through the powerOn operation and exited through the powerOff operation. As we will see later, we can have multiple operations entering and exiting a single state.

Now let's start our vending machine, so we can explore the core state machine concepts supported by BSM and how they are presented in Integration Developer.
Implementation
We will complete the following steps to develop BSM using Integration Developer.
                             Ø  Create Artifacts.
                             Ø  Create BSM.
                             Ø  Implement BSM.
                             Ø  Test BSM.
Create Artifacts:
Create a library called ‘EAI_Library’ and create two interfaces as shown below.


Create BSM:
Create a Module called ‘EAI_VendingMachineModule’ and create a Business State Machine.
Right click on Integration Logic àNew àBusiness State Machine.
Give the name as ‘BSM_VendingMachine’ and click on next.
Select the interface ‘VendingMachineMaintenanceInterface’ and operation name ‘powerOn’. Select the input ‘SerialNumber’ for correlation information.
Now the initial BSM Looks like below.
Implement BSM:
Create three variables called SerialNumber (String), DepositAmount (Int), and TotalAmount (Int) under Variables section.
Select the wire and Right click àAdd àOperation.
Select the newly added operation àProperties àSelect interface ‘VendingMachineMaintenanceInterface’ and operation ‘powerOff’.
Select wire near PowerOn operation and click on Add an Action.
Rename as initialize and select Properties àDetails àJava, and then add the following code.
Select the Running status then add the entry and add the following code under properties à Details àJava.
Drag and drop a Simple activity from Pallet and rename as Collecting.
Add ‘VendingMachineInterface’ interface to the BSM.
Drag a wire from Running status to Collectingstatus. Select VendingMachineInterface interface and deposit operation.
Add and action to deposit operation and writ the following code.
Drag a wire from running ‘Collecting’ status to ‘Collecting status to implement a loop. Add an operation deposit and add an action then add the following code.
Drag a wire from collecting status to runningstatus. Add an operation coinReturnand add an activity rename as ReturnMoneythen add the following code.
Select and activity for PowerOff operation rename as Shutting Down and write the following code at property window.
Now select the CorrelationProperty1 àProperties àDescription then click on Add button.
Enter the XPath to select correlation variable from each operation.
Now the final correlation property will be look like below.
We have implemented Business State Machine, Open assembly diagram and drag and drop ‘BSM_VendingMachine’ on assembly diagram.
Test BSM:
We have completed Business State Machine implementation. Now we can test this by using component test method. Start the WPS server and Deploy the ‘EAI_VendingMachineModule’ module.
Open Assembly diagram and right click on ‘BSM_VendingMachine’ select Test Component.
Now it will open Integration Test Client, select the interface ‘VendingMachineMaintenanceInterface’ and operation powerOn, enter SerialNumber as 111 the click on continue.
Then click on invoke symbol, it will open new invoke test run, select ‘VendingMachineInterface’ and deposit interface then give SerialNumber as 111 and DepositAmount 100 then click on continue.
Repeat the above step for test returnCoin and PowerOffoperations. The final result will be look like below.
The successful transaction logs will be printed to SystemOut log and console as shown below.
Conclusion
In this article, we learnt to implement the vending machine using BSM. This provided our first self-transition, the addition of variables, and actions. We then used the component test. We discussed the differences between BPEL processes and BSMs, with specific regards to how state machines provide a good solution for "nouns" that are event driven and have looping.
Download
File Name
Description
 Size
Download
BSM Sample.zip
BSM Sample
15 KB
BSM in WPS.pdf
BSM in WPS Document
1.02 MB

continue reading

Wednesday, February 12, 2014

Clearing the Java class caches in IBM WAS, WPS & WESB

Abstract:
Instructions on clearing the java class caches in IBM WebSphere Application Server, WPS & WESB. The JVM's shared class cache and WebSphere Application Server's, WebSphere Process Server and WESB OSGi class cache.
Resolution:
The main reason behind cleaning caches is to delete old class references which have been taken the WebSphere Servers. After an upgrade, it is possible that the class caches are still holding onto previous versions of classes. It is also possible that the caches became corrupted. The best practice to keep our server with updated classes is to clean caches after upgrade of applications.
We need to clean two caches, the JVM's cache and the OSGi cache. The server has to be stopped before clearing the cache.

To clear the OSGi class cache:
For UNIX platforms, run the following script in each profile:
<WebSphere_HOME>/profiles/profile_name/bin/osgiCfgInit.sh
Example:
WAS: /app/wasv7/profiles/was01/bin/osgiCfgInit.sh
WPS: /app/wpsv7/profiles/wps01/bin/osgiCfgInit.sh
WESB: /app/wesbv7/profiles/wesb01/bin/osgiCfgInit.sh
For Windows platforms, run the following script in each profile:
<WebSphere_HOME>\profiles\profile_name\bin\osgiCfgInit.bat
Example:
WAS: C:\IBM\WebSphere\AppServer\bin\osgiCfgInit.bat
WPS: C:\IBM\WID7_WTE\runtimes\bi_v7\profiles\qwps\bin\osgiCfgInit.bat
WESB: C:\IBM\WID7_WTE\runtimes\bi_v7\profiles\qesb\bin\osgiCfgInit.bat

To clear the JVM class cache:
For UNIX platforms, run the following script in each profile:
<WebSphere_HOME>/bin/clearClassCache.sh
Example:
WAS: /app/wasv7/profiles/AppServer/bin/clearClassCache.sh
WPS: /app/wpsv7/profiles/wps01/bin/clearClassCache.sh
WESB: /app/wesbv7/profiles/wesb01/bin/clearClassCache.sh
For Windows platforms, run the following script:
<WebSphere_HOME>\bin\clearClassCache.bat
Example:
WAS: C:\IBM\WebSphere\AppServer\bin\clearClassCache.bat
WPS: C:\IBM\WID7_WTE\runtimes\bi_v7\profiles\qwps\bin\clearClassCache.bat
WESB: C:\IBM\WID7_WTE\runtimes\bi_v7\profiles\qesb\bin\clearClassCache.bat

And clear the following directory contents:
<WinUsers_home>\Local Settings\ApplicationData\javasharedresources\


Where WinUsers_home is either C:\Documents and Settings\DefaultUserOR C:\Users depending on your current version of Windows.

continue reading

Friday, January 31, 2014

Defining and Validating Business Objects in IBM WPS

Introduction
This article focuses on the XML aspects of business objects in WebSphere Process Server. It explains how a business object is defined, how to create and validate a business object. IBM customers require that business object (BO) instances are validated in runtime from the defined XSD (XML schema definition) constraints. This validation is desired by specific business systems to ensure data consistency and accuracy. Since version 6.1, WebSphere Process Server has provided BO instance validation support in runtime. This function confirms that the data passed into an operation matches the XSD types and constraints of the operation's inputs.
Overview
There are two ways to validate BO instances:
Ø  Utilize the data validation qualifier
Ø  Invoke the BO Instance Validator APIs
This article focuses on business objects validation in WebSphere Process Server. It demonstrates how to create business objects with constraints and how to validate business object instances in the runtime from the defined constraints.
Business Objects are SOA core components and it provides an abstraction layer for data objects. Business Object Framework is intended to provide data abstraction for service component. Component interfaces use Business Objects as inputs and outputs.
Business objects are modeled using xml schemas (XSD).
At run time BO's are represented in memory as an SDO instance using commonj.sdo.DataObject
Business Objects are collection of elements with names and data types.
We have two types of business objects:
                 1. Simple business object composed of scalars
                 2. Hierarchical business objects with elements that contain other business objects.
Business object compare utility shows the structure of business objects in two different modules or libraries and allows you to visually determine additions, removals, and changes. Also the "Copy Report to Clipboard" option allows you to paste changes into a document or other report.
Implementation
We will learn the following things in this article.
Ø  Defining Business Objects.
Ø  View Business Objects in XML.
Ø  Add attribute in Business Object.
Ø  Defining business objects with constraints.
Defining Business Objects:
We start by examining the sample module containing two simple business objects and one complex business object.
Create a module called ‘EAI_BusinessObjectsModule’.
Right click on EAI_BusinessObjectsModule àNew àBusiness Object.
Give name as ‘AccountDetails’and click on finish. Add the fields to business object by clicking on add fields to business object. The AccountDetails business object is look like below.
Similarly create a business object called Address.
Now we will learn how to create a complex business object. The business object which contain other business object as a data type called as complex business object.
Create a business object called ‘Customer’ with one of the field name ‘Address’. Click on browse button near data types.
Select the Address business object which we have created previously. The complex business object ‘Customer’ looks like below.
View Business Objects in XML
Right click on AccountDetails à Open with à XML Schema Editor
See the below screen shot, it will show the business object in XML schema with all fields and type.
Add attribute in Business Object
Open business object in XML schema editor and add the following code into xml file.
<xsd:attribute name="BranchID" type="xsd:string" />
When we open business object in business object editor, it will look like below.
Defining business objects with constraints
We can define a constraint values for a field in business object. So it will allow only those type of constraint will allow during runtime. For example, if we want allow Account type only with Saving Account or Current Account. We can define these two constraints to Account Type field in a business object.
Defining the Enumeration constraint
Open ‘AccountDetails’ business object then select ‘Account Type’ field à Properties à Description.
Select ‘Only permit certain values’ check box and select ‘enumerations’ button. Click on add give the constrain value ‘Saving Account’ and click on Ok.
Repeat the same steps for adding two more constrains for the account type. Finally AccountDetails business object will be look like below.
Defining the Pattern constraint
Open ‘Customer’ business object then select ‘Phone’ field à Properties à Description.
Select ‘Only permit certain values’ check box and select ‘Patterns’ button. Click on add give the pattern value range 10 to 13 and click on Ok.
Conclusion
In this article, we learned how business objects are defined and the best practices to follow. We learned how to use WebSphere Integration Developer to create and validate XML documents prior to sending them to WebSphere Process Server. We can invoke this service for either implicit interface qualifier-based validation, or for validating business objects in WebSphere Process explicit programmatic validation. We learned how business objects with constraints are defined and how business object instances are validated. By following these recommendations, we will have a stable, flexible, and reusable library of types for your solution.
Downloads
File Name
Description
      Size
Download
Business Object Sample.zip
Business Object Sample
11 KB
Business Objects in WPS.pdf
Business Objects in WPS Document
750 KB

continue reading

Designed By AMEER BASHA G