Sunday, November 17, 2013

Inter Process Communication with Send and Receive Tasks using Correlations


(JDeveloper 11.1.1.6, WLS 10.3.6, SOA/BPM 11.1.1.6)

Following is a simple approach to use inter process communication in BPM using Send and Receive tasks using Correlations.

I created two simple BPM processes, first process as shown below will start and wait at the Wait (Receive Task).
When the process instance is created, the correlation also gets instantiated.
In this case, the correlation key is the input parameter to the Start task of the process.
It takes the input and sets the correlation key for that process instance.

First we need to Initiate the correlation keys at Start.
Also, we have to set the data mappings.



Then we need to use the Correlation keys on the Wait (Receive Task)



The second process is the process which will call the first process with a Send activity by passing the value of the data for specifying which process instance to pick up using the correlation key.
We use the Send message activity to call the First process by passing the value of the correlation key to get the correct process instance.



Testing

I instantiated 3 instances of the first process with data values 101, 102, 103 (these are set as correlation keys)


I called the second process by passing the value 102.


The second process completes and which calls the instance 102 of the first process at the receive task and because of which the 102 instance is also completed.




   

Monday, July 15, 2013

Implementing Business Rules in BPM Processes

Implementing Business Rules in BPM Processes
(JDeveloper 11.1.1.7, WLS 10.3.6, SOA/BPM 11.1.1.7)


In this post I would like to show how to implement Business Rules in Oracle BPM Processes.


Let us assume a scenario where an employee wants to travel on business and it needs manager’s approval on certain scenarios as the following table. All other cases it is automatically approved.


Destination Type
Duration (Days)
Business Class
Amount ($)
International



Domestic
> 30


Domestic

Y

Domestic


> 1000


  1. Create a BPM Application with a manual process



  1. Define a business object with the following attributes



  1. Modify the process as follows and create Human tasks and Business rule

  1. Create Business Rules as follows



  1. Open the Business Rules editor and select Rulesets and change the Ruleset name to “Manual Approval Ruleset” and create a Decision table for the View property and name it as “Approval Decision Table”.



  1. Build Decision table as follows according to the above table



  1. You can create LOVs dynamically as follows which will create the Bucketsets


  1. Similarly you can create ranges for duration and expense amounts also


  1. You can select the values from the LOVs as shown below from all the bucketsets for destination types, duration and amounts



  1. Fill the Actions section for all the Rules for the manualApprovalRequired, reviewOutcome attributes selecting ‘modify’ as the action


  1. Validate the Business Rules as shown below and make sure there are no warnings or errors



  1. Set the condition for the conditional flow for ‘Is Auto Approved’ exclusive gate as follows




  1. Assign the output data mapping for Review Travel Expense task as follows



  1. Build the project and build the ADF UI project for the Human Tasks UI. For more detailed steps follow my previous blog here.


  1. Assign users to the roles in Organization file.


  1. Deploy the application and test


  1. Login as the employee and request the travel expense approval, with auto approval condition



  1. The travel request is auto approved.



  1. Request another travel expense with any of the approval required conditions



  1. The request will go for managers approval



Thursday, July 4, 2013

Importing BPM Projects to Composer using MDS Connection from JDeveloper

(JDeveloper 11.1.1.7, WLS 10.3.6, SOA/BPM 11.1.1.7)


The following is a simple procedure to import the BPM Projects from JDeveloper to SOA MDS Repository and open the Processes in Oracle BPM Composer.


  1. Open the BPM Application in JDeveloper





  1. Open the BPM MDS Navigator and Configure an MDS connection





  1. Create a BPM MDS Connection, SOA MDS Connection, and Database Connection to DEV_MDS database as follows. The DEV_MDS database connection is the one you have created while installing the RCU in the SOA installation process.

  1. Look at the WLS Console Data Source for DEV_MDS for details





  1. Make sure all the connections are tested successfully.





  1. Open the BPM Project Navigator in JDeveloper and Save to BPM MDS





  1. Click Ok for the following dialog





  1. After the project is saved, login to the BPM Composer as weblogic administrator login and you can see the project imported already





  1. Click on the project and it will take you to the project home.
  2. Also, if we create a project/process in the BPM Composer, it will be visible in the MDS Navigator in the JDeveloper.



Saturday, June 1, 2013

Runnable ADF Projects in JDeveloper Integrated WLS within BPM Application

(JDeveloper 11.1.1.7, WLS 10.3.6, SOA/BPM 11.1.1.7)


In my previous blog, I created a separate ADF project in the BPM Application for showing the custom database related UI.
We can imagine a scenario where I have to develop only the ADF page, and it might take a couple of trials until I get the UI right.
So each time I modify the ADF code, if I have to deploy the whole BPM application to the Weblogic server and test it from the BPM workspace, it is a time consuming process.

Instead, I should be able to run only the ADF code (not the Task Forms created from the Human Task definitions, but the ADF pages/taskflows created based on custom DB) in the JDeveloper Integrated Weblogic server and test it.

By default, if we try to run the ADF pages inside the BPM application we might get errors.
(The error is shown at the end of this blog)
Integrated Weblogic server starts complaining about the SOA libraries coming from the project and the page will not be runnable.


To make the ADF code runnable in Integrated Weblogic server, we have to do a couple of settings in JDeveloper and modify some project code as follows.

1. Use Current Working Set


2. Uncheck BPM/SOA related projects in Manage Working Sets


3. Comment the adf-mds-config tag in the adf-config.xml



4. Comment the BPEL and SOA libraries in the weblogic-application.xml



5.  Create a test page in the common UI project and reuse the bounded taskflows.


6. Pass parameters as required to the taskflows


The pages will be running in the JDeveloper Integrated Weblogic Server.



The error we might get will be as follows.

[Running application EmplyeeBookRequests on Server Instance IntegratedWebLogicServer...] 
[10:20:27 PM] ----  Deployment started.  ----
[10:20:27 PM] Target platform is  (Weblogic 10.3).
[10:20:31 PM] Retrieving existing application information
[10:20:31 PM] Running dependency analysis...
[10:20:31 PM] Deploying 2 profiles...
[10:20:31 PM] Wrote Web Application Module to C:\Users\Sameer\AppData\Roaming\JDeveloper\system11.1.1.7.40.64.93\o.j2ee\drs\EmplyeeBookRequests\EmployeeBookRequestCommonUIWebApp.war
[10:20:31 PM] Wrote Enterprise Application Module to C:\Users\Sameer\AppData\Roaming\JDeveloper\system11.1.1.7.40.64.93\o.j2ee\drs\EmplyeeBookRequests
[10:20:31 PM] Redeploying Application...
<Jun 1, 2013 10:20:32 PM EDT> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID '1370139631714' for task '0'. Error is: 'weblogic.management.DeploymentException: [J2EE:160149]Error while processing library references. Unresolved application library references, defined in weblogic-application.xml: [Extension-Name: oracle.soa.workflow.wc, exact-match: false].'
weblogic.management.DeploymentException: [J2EE:160149]Error while processing library references. Unresolved application library references, defined in weblogic-application.xml: [Extension-Name: oracle.soa.workflow.wc, exact-match: false].
at weblogic.application.internal.flow.CheckLibraryReferenceFlow.prepare(CheckLibraryReferenceFlow.java:26)
at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:613)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:184)
at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:58)
Truncated. see log file for complete stacktrace
<Jun 1, 2013 10:20:32 PM EDT> <Warning> <Deployer> <BEA-149004> <Failures were detected while initiating deploy task for application 'EmplyeeBookRequests'.> 
<Jun 1, 2013 10:20:32 PM EDT> <Warning> <Deployer> <BEA-149078> <Stack trace for message 149004
weblogic.management.DeploymentException: [J2EE:160149]Error while processing library references. Unresolved application library references, defined in weblogic-application.xml: [Extension-Name: oracle.soa.workflow.wc, exact-match: false].
at weblogic.application.internal.flow.CheckLibraryReferenceFlow.prepare(CheckLibraryReferenceFlow.java:26)
at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:613)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:184)
at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:58)
Truncated. see log file for complete stacktrace
[10:20:32 PM] ####  Deployment incomplete.  ####
[10:20:32 PM] Remote deployment failed
#### Cannot run application EmplyeeBookRequests due to error deploying to IntegratedWebLogicServer.
[Application EmplyeeBookRequests stopped and undeployed from Server Instance IntegratedWebLogicServer]


Payload Or Database ?



(JDeveloper 11.1.1.7, WLS 10.3.6, SOA/BPM 11.1.1.7)

Not all data can be stored, or is recommended to be stored in the Payload. Especially the Transactional or Relational data. They are as usual should be stored in the Database.

So let us assume that we keep the Transactional and Relational data in the Database.
We still need to keep some data in the Payload for the process to function properly.
We keep only that data in the Payload that will affect the flow in the Process.
During the progress of the Process we might have to change some Payload values which will affect the flow of the process.

BPM might not know about the data we store in the Database. Most of the cases it will be Custom data. So it is our responsibility to maintain an association between the Process and the custom data in the database.

In this post, I would like to show a logic which can maintain a relation between the custom data and the process.

Either the unique process instance id can be stored in our database table (most cases it will be the main entity of the application), or put the main entity's primary key in the Payload.
I would recommend the first option, put the process instance id in the main entity database table.


The use case I assumed for this is a BPM process of book requests for employees.
Following is the database table I created for holding the book requests information.




Created a simple process as follows for the book request



Created a UI project for BPM Human Tasks as follows


Create another ADF Model Project in the same application and create the necessary BC4J objects based on the UI requirements.




Create another ADF View Controller project in the same application and create a bounded task flow in the common UI project





Create a task flow parameter for the bounded task flow to get the bpm process instance Id.




Create the Book Request form from the data controls in the page




Add a View Criteria to the VO as follows




Add a method to the AM as follows 




And Create a client interface for that method


Add the method to the task flow as follows by passing the parameter from the page flow scope and make it the default activity.



Open the common UI project deployment profile and create an ADF Library JAR file


Create the jar library file


Create a new file system connection to the deploy folder of the common UI project



Select the BPM UI project and add the library to the project



It should show like below if it is added successfully


Create a binding on the BookRequest page for process instance id from the data control for RequestBook task as follows. You can hide this if you want. It is not necessary to show it to the user.


Drag and drop the taskflow from library as region to the BookRequest page in the BPM UI project as follows



Pass the instance id from the page binding as follows as parameter to the taskflow region



Do the same for ReviewBook and ResponseBook pages

Also, we have to add Commit binding to all the 3 pages. This should be called programmatically on Submit button. (Not shown in this post)



Deploy the application and test.

Login as Employee and create a book request and Submit. (We have to save manually here first. – Should actually call the commit binding on Submit button code)


The Manager will get a task for reviewing the book request.

Here the book request region is same from the library and is fetching the data from the database using the bpm process instance id.



Please look at my previous post for detail steps to create a BPM process.