Showing posts with label HumanTask. Show all posts
Showing posts with label HumanTask. Show all posts

Thursday, April 28, 2016

[Sample] Order Processing Process

This sample illustrates usage of WS-BPEL 2.0, WS-HumanTask 1.1 and Rule capabilities in WSO2 Business Process Server and WSO2 Business Rule Server.


Order Processing Flow
alt text
  • The client place an order by providing client ID, item IDs, quantity, shipping address and shipping city.
  • Then Process submits order information to invoicing web service, which generates order ID and calculate total order value.
  • If total order value is greater than USD 500, process requires a human interaction to proceed. When a order requires a human interaction process creates a Review HumanTask for regional clerks. If review task is rejected by one of regional clerk user, workflow terminates after notifying the client.
  • Once the regional clerk approve the review task, workflow invokes Warehouse Locater rule service to calculate nearest warehouse.
  • Once receiving nearest warehouse, process invokes Place Order web service to finalize the order.
  • Finally user will be notified with the estimated delivery date.

This sample contains

Please checkout this sample from Github. 

Monday, October 20, 2014

Book Review : WS-BPEL 2.0 Beginners Guide

WS-BPEL 2.0 Beginners Guide: As name suggest, This is a good reading for who wants to learn BPEL concepts from beginning. Authors start book with a very simple BPEL sample. They give details instructions from setting up IDE, creating schema and wsdl, etc. They finish their first sample giving instructions to how you can test your first BPEL process using a BPEL engine. That is why I recommend this book as a true beginner guide.

BPEL specifications is so long and even BPEL 2.0 primer is very hard to understand without prior knowledge on BPEL. But authors have structured book chapters from simple to complex BPEL concepts, so that beginners can easily understand. It contains chapters for fault handling, compensation, parallel processing  asynchronous invocation etc. Best part is authors have given samples for each section including guidance how you can do it in IDE.

This book contains special chapter for Humantask with samples. That adds a true value to this book.

Even BPEL 2.0 is published in 2007, (Nearly 7 years ago) it is usage is increasing in enterprise world. It is an widely used industrial standard for Business process management (BPM). I think knowing BPEL is an added advantage for a programmer, architect and students; and this is the best book to start with.

Have a look on this book by clicking this link.

Saturday, May 17, 2014

WSO2 BPS 3.2.0 - Performance Tuning - Know When, Why and How


  • Following instructions are only applied to WSO2 BPS 3.2.0
  • All configuration files are located under $WSO2BPS-3.2.0_HOME/repository/conf/ directory

JDBC connections.

When ?

  • When your application requires high throughput  

Why ?

  • BPS server has two engines; Apache ODE BPEL processor and HumanTask engine. These two engines are tightly coupled with database layer. They persist every instance data into database. Thus to function BPS properly, you need to allocate enough database connections for BPS datasource.
  • Both these engine share same BPS datasource and db connections. Thus generally we are recommending to allocate db connections 50-50 manner for a BPEL + HumanTask application.
  • For example if you have total 100 db connections, for a BPEL + HumanTask application, you can use upto 50 db connections for ODE engine and leave the rest of the db connections for HumanTask operations.
  • If you have only BPEL usecase, you can allocate many db connections ( see next topic) for ODE engine. 
  • Also note that, even you have allocated higher number of db connections for BPS datasource, performance may not increase as excepted. One reason would be, there are no enough db sessions from database side. If that is the case, you need to increase number of db session from database side.  

How ?

  • Configure BPS data source using datasources.properties file.
  • eg: see highlighted section. 
 ...
 synapse.datasources.bpsds.validationQuery=SELECT 1 FROM DUAL
 synapse.datasources.bpsds.dsName=bpsds
 synapse.datasources.bpsds.maxActive=100
 synapse.datasources.bpsds.maxIdle=20
 synapse.datasources.bpsds.maxWait=10000

 

ODE Scheduler threads

When ?

  •  When your application requires high throughput  

Why ?

  • In ODE engine, every scheduler thread is associated with a db connection. So the rule of thumb is, number of ODE scheduler threads should be less than or equal to number of db connections allocated for ODE engine. Otherwise some threads may not work properly, because they can't acquire a db connections to work. 
  • For example In BPEL + HumanTask scenario, if you have total 100 db connections, your can allocate 50 threads for ODE scheduler. This will grantee that at a given time, only 50 db connections are acquired by ODE engine.    

How ?

  • Configure this via bps.xml.
  • eg: 
    <tns:odeschedulerthreadpoolsize>50</tns:odeschedulerthreadpoolsize>

HTTP connections

When ?

  • When your have lot of service invocations.(external or internal) 

Why ?

  • When your BPEL processes do service invocations, they use http connections. By default this http connections are limited. Because of this, thread have to waits for http connections. 
  • To avoid this, you can increase this value using Multithreaded Http Connection Manager Configuration. 
  • If your processes do lot of service invocation to localhost ( or particular host), then it is required to increase maxConnectionsPerHost configuration as well.

How ?

  •  enable this configuration using bps.xml

    <tns:MultithreadedHttpConnectionManagerConfig>
        <tns:maxconnectionsperhost value="350">
        <tns:maxtotalconnections value="400">
    </tns:maxtotalconnections>

 

TimeOuts 

When ?

  •  When partner services take more time (slow) to response.

Why ?

  • When partner services are slow or take more time to response, callee BPEL process's invoke activity fails due to message exchange timeout. By increasing time will avoid these kind of failures. 
  • Also note that, slow partner services will slow entire BPEL process. This will cause to timeout the client application. ( callee of the BPEL process.). Thus it is required increase timeout interval for client application.      

How ?

  • Via bps.xml and axis2.xml
Read for more information.
http://nandikajayawardana.blogspot.com/2012/10/how-to-increase-external-invocation.html

 

HumanTask Caching 

When ?

  • When you have to deal with large user store.

Why ?

  • HumanTasks are tightly coupled with users and user roles/groups. Because of this, BPS does lot of user store lookups for HumanTask operations. These user store calls can take considerable amount of time, if user store is large or located remotely. This causes to degrade performance of the entire HumanTask engine. Caching user and role lookup data at BPS side will reduce those remote user store calls and improve overall HumanTask engine's performance.  

How ?

  • Enable HumanTask caching in humantask.xml
  • eg: 
    <cacheconfiguration>
        <enablecaching>true</enablecaching>
    </cacheconfiguration>

 

Number of HumanTask Scheduler threads.

When ?

  • When you are not using humantask deadline/escalation.

Why ?

  • HumanTask deadline and escalation are scheduled tasks, which are executed by HumanTask scheduler. By default 50 threads are allocated for HumanTask scheduler. If you are not using deadline/escalations, you can configure this value to lower value such as 5. This will utilize idle threads in BPS server.
  • Note that, you can't set this to 0, because humantask engine has several internal scheduled tasks to run.

How ?

  • Configure this value in humantask.xml,
  • eg:
    <schedulerconfig>
        <maxthreadpoolsize>5</maxthreadpoolsize>
    </schedulerconfig>

Sunday, May 4, 2014

An Async BPEL Process and A Human task ?

In Async process ( in other words a long running process ), after the invocation of a partner process or service, the BPEL process continues to carry on with its execution process while that partner service completes performing its operation. This partner service may take couple of seconds, minutes, hours or even days to complete. The Async BPEL process then receives the result of the partner service via a callback service, when the partner service is completed.

HumanTask (Web service) is one type of such a long running partner service which returns the task result when user completes the task. In this case, BPEL use B4P extension, which stops the BPEL execution flow which contains the B4P extension activity and waits till HumanTask output to come.

Tuesday, March 18, 2014

Running HumanTask Cleanup Job - WSO2 BPS

HumanTask engine allows you to configure periodic cleanup tasks from the WSO2 BPS persistence storage based on task status. To enable Task clean up task, uncomment TaskCleanupConfig element in HumanTask.xml


HumanTask engine uses quartz-scheduler for cron jobs. Refer [1] to declare cron expressions format. In above example, Cron scheduler will trigger TaskCleanup task every Four Hours, to remove COMPLETED, OBSOLETE, EXITED from the database.

[1] -http://www.quartz-scheduler.org/documentation/quartz-1.x/tutorials/crontrigger


Saturday, May 25, 2013

HumanTask Event Listeners - WSO2 BPS


HumanTask engine comes with a humantask event generator. These task events are generated when a task goes trough a state transition. An event contains details about tasks and its state transition. So by writing a custom event listener to these events, a developer can easily enhance the HumanTask engine's functionalities.

What developer can do with a task event listener.
  • Can do custom java code/ web service invocations.
  • Can retrieve task information. 
  • Developer free to implement their own logic depending on their requirement.

Sample Event Listener.

EventListener class should implement HumanTaskEventListener class and onEvent method. See following sample code.


How to deploy a custom listener to WSO2 BPS

  1. Build a jar file of including your listener.
  2. Copy it into /repository/components/lib. Where is the root directory of BPS server.
  3. Uncomment TaskEventListeners in HumanTask configuration file (/repository/conf/humantask.xml) and give your Event Listener class name for ClassName.
  4. eg:
    Note: you can have multiple listener classes.
  5. Start BPS.
  6. Execute a task.

Escalating a human task with WSO2 BPS.

This Post describes, how to you can define a deadline within a human task. For this I am going to extend WSO2 BPS Claim Approval Task sample.

Prerequisite

  • If you haven't tried the sample yet, try it first. So you get better idea about how human task works.
  • Download WSO2 BPS 3.0.0 +
  • an Text Editor.

Note: You can find more information about humantask deadlines and timeouts under section 4.9 in humatask specification. 

What I am going to do in this sample ...

In this sample, I have set deadline time duration for 5 minuets after task creation. The escalation is defined such a way that, if the claimed amount is less than 10000 and task not started within 5 minutes, then notify task's potential owners that current claim approval task is overdue.

Steps to Modify WSO2 BPS Claim Approval Task sample


1)  Setup BPS as mentioned in sample page.

Deploy BPEL package. Creates Roles and Users. But do not deploy humantask package ClaimsApprovalTask.zip since we are going to modify it in next steps.

2) Modify ClaimsApprovalTask.ht

Unzip ClaimsApprovalTask.zip and Add following deadline definition (i.e <htd:deadlines>) inside ApproveClaim task definition (i.e. <htd:task "ApproveClaim"> ) in ClaimsApprovalTask.ht


3) Replace ClaimsApprovalTaskService.wsdl

I did slight changes to wsdl file for this sample. So replace ClaimsApprovalTaskService.wsdl with this file.

4) Deploy Sample

Create new zip file including all files.(modified and unmodified) and deploy it in BPS.
( you can find modified sample from here )

5) Send a Sample Request.

After deployment, send a sample request (like given in sample page). You can see task is created under clerk login. Do not start the human task.

6) Wait 5 mins.

After 5 mins, deadline will be executed. As a result this, a notification is generated and sent to the clerk. Clerk can view notification under Home -> Human Tasks -> Notifications.