WSO2 Business Process Server v3.1.0 Documentation

##### Overview

- Home
- Release Note
- WS-BPEL Compliance
- License

##### Downloads

- Releases

##### Installation Guide

- Installing WSO2 BPS

##### Quick Start Guide

- Modeling the process
- Deploying the process
- Testing the process

##### User Guide

- Deploying BPEL Processes
- Deploying Human Tasks
- Managing BPEL processes
- Managing BPEL process instances
- QoS for BPEL processes
- Securing BPEL processes
- Invoking secured partner services
- Versioning
- Management API

##### Human Task Guide

- Human Tasks Quick Start Guide
- Deploying HumanTasks
- Managing Tasks
- Developing a Human Task Artifact
- Human Task Management and Configuration
- Human Task Concepts

##### Administrator Guide

- External data sources Configuration
- Registry Configuration
- Events
- Unified Endpoints
- BPEL Extensions
- Transaction Factory Configuration
- Message Exchange Interceptors
- OpenJPA specific properties
- JMS Transport Configuration
- Process Instance Cleanup Tasks
- Process Hydration and Dehydration
- Enabling Peer-to-Peer(P2P) Communication
- Setting up a BPS Cluster

##### Best Practices

- Process Deployment Best Practices

##### Concepts

- Process Versioning
- Process instance events
- Partner links

##### WS-BPEL Extensions

- Activity Failure and Recovery
- Extension Activities and Extensible Assign Operations
- XPath Extensions
- Iterable ForEach
- Flexible Assigns
- BPEL4People Extension

##### Samples

- HelloWorld
- If-Else
- ForEach
- While
- Repeat Until
- Flow and Links
- Pick
- Synchronous and Asynchronous Service Invocations
- Fault Handling
- Split
- XslTransform
- Compensation Handler
- Event Handler

##### Resources

- FAQ
- External Articles
- Library
- Source Code

##### Community

- Forum
- Mailing Lists

##### Project Information

- Issue Tracking

# Sample Guide - Pick

### Table of Content

- Objective
- Prerequisites
- Overall Idea

### Objective

<pick/> can be used for event based execution. Inside <pick/>, we can define activities to be executed when there is an event or a set of events occur. These events can be defined in <onMessage/> or <onAlarm/>. <onMessage/> is used to define events based on arrival of a message. <onAlarm/> is used to define events based on specific time point or time interval. <pick/> activity should include at least one <onMessage/> element while <onAlarm/> is optional. Additionally user have to define a correlation set and refer it in each event in-order to determine the correct execution path.

eg - Let's take PickProcess.bpel in TestPickOneWay.zip (sample is located at our sample repository.)

This bpel process can be invoked by 5 operations. Those operations are dealDeck, pickSpade, pickClub, pickHeart and pickDiamond.

eg -

-     <receive operation="dealDeck" partnerLink="IncomingLink" variable="deckRequest" createInstance="yes" .../>

-     <onMessage operation="pickSpade" partnerLink="IncomingLink" variable="spadeRequest" .../>

-     <onMessage operation="pickClub" partnerLink="IncomingLink" variable="clubRequest" .../>

-     <onMessage operation="pickHeart" partnerLink="IncomingLink" variable="heartRequest" .../>

-     <onMessage operation="pickDiamond" partnerLink="IncomingLink" variable="diamondRequest" .../>

So once one of these operations is executed, the bpel process is invoked. But only "dealDeck" operation can create an instance of this process as its createInstance attribute is set to "yes". If one of the other operations are executed, a job will be queued until an instance is created. So once an instance is created, the queued job will be triggered.

### Prerequisites

- Log in into BPS server admin console.
- Under Business Processes -> Add BPEL.
- Upload the TestPickOneWay.zip , (all samples are located at our sample repository.)
- Under the Business Processes -> Processes.
- Under the WSDL details widget -> Create instance

### Overall Idea

refer TestPickOneWay.zip

- Defining correlation set.

      <correlationSets>
          <correlationSet name="CorrelationByDeck" properties="srvns:deck"/>
      </correlationSets>

  This property is defined at PickService.wsdl as follows.

      <vprop:property name="deck" type="xsd:token"/>
      <vprop:propertyAlias messageType="tns:dealDeckRequest" part="parameters" propertyName="tns:deck">
          <vprop:query>tns:Deck</vprop:query>
      </vprop:propertyAlias>

  Here the property points to a particular message element which is called <Deck/> in the `dealDeckRequest` message type.

  eg -

      <dealDeck>
          <Deck></Deck>
      </dealDeck>

- So once a message of the type `dealDeckRequest` is received, an instance of correlation set will be created based on the value of the element <Deck/>.
- In this sample, when a `dealDeckRequest` message is received a process instance is created due to`createInstance="yes"`. As well a correlation set instance is also created due to`initiate="yes"`.

      <receive operation="dealDeck" partnerLink="IncomingLink" variable="deckRequest"
               createInstance="yes">
          <correlations>
              <correlation initiate="yes" set="CorrelationByDeck"/>
          </correlations>
      </receive>

- Suppose there's a incoming message for a operation defined in <onMessage>. So once the message is received to the process, it'll be verified with correlation set instance. If there's an existing process instance, which is compliant with the correlation set instance, then the instance will execute the particular set of activities defined.
- If the incoming message's operation is "pickSpade", and the partnerLink is "IncomingLink" , and the incoming message is compliant with the correlation set instance of the process instance, following activities are executed.

      <onMessage operation="pickSpade" partnerLink="IncomingLink" variable="spadeRequest">
          <correlations>
              <correlation initiate="no" set="CorrelationByDeck"/>
          </correlations>
          <sequence>
              <assign>
                  <copy>
                      <from>
                          <literal>
                              <pickSpadeResponse xmlns="http://www.stark.com/PickService">
                                  <Deck/>
                              </pickSpadeResponse>
                          </literal>
                      </from>
                      <to variable="spadeResponse" part="parameters"/>
                  </copy>
                  <copy>
                      <from>bpel:getVariableProperty("spadeRequest", "srvns:deck")</from>
                      <to>$spadeResponse.parameters/srvns:Deck</to>
                  </copy>
              </assign>
              <reply operation="pickSpade" partnerLink="IncomingLink" variable="spadeResponse"/>
          </sequence>
      </onMessage>