This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.
Pick Construct
Objective
This sample illustrates <pick/>, where a process instance execution can be specified based on a particular received event. The received event can be <onMessage/> or <onAlarm/>. Additionally, users have to define a correlation set and refer it in each event in order to determine the correct execution path.
Deploying the Sample
WSO2 BPS provides a sample, which can be deployed and executed to understand the Pick construct. Follow the instructions below to deploy and trigger the process.
1. Log in into BPS server management console and select "Processes -> Add" under the "Main" menu.
2. Upload the PickOneWay.zip found in the BPS_Home/repository/samples/bpel
 directory. (Samples are also located at our sample repository).
3. In the "Deployed Processes" window, click the "Process ID" to access its "Process Information" window.
4. Under the "WSDL Details" widget, trigger the process using the "TryIt" link to create an instance of it.
Example Usage
Refer to PickOneWay.zip when going through the following instructions.
Defining correlation set
<correlationSets> <correlationSetname="CorrelationByDeck"properties="srvns:deck"/> </correlationSets>
This property is defined in the PickService.wsdl as follows.
<vprop:propertyname="deck"type="xsd:token"/> <vprop:propertyAliasmessageType="tns:dealDeckRequest"part="parameters"propertyName="tns:deck"> <vprop:query>tns:Deck</vprop:query> </vprop:propertyAlias>
The property points to a particular message element which is called <Deck/> in the dealDeckRequest
message type. For example,
<dealDeck> <Deck></Deck> </dealDeck>
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"
. Also, a correlation set instance is created due to initiate="yes"
.
<receiveoperation="dealDeck"partnerLink="IncomingLink"variable="deckRequest"createInstance="yes"> <correlations> <correlationinitiate="yes"set="CorrelationByDeck"/> </correlations> </receive>
Suppose there's an incoming message for an operation defined in <onMessage>. 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", the partnerLink is "IncomingLink", and the incoming message is compliant with the correlation set instance of the process instance, following activities are executed.
<onMessageoperation="pickSpade"partnerLink="IncomingLink"variable="spadeRequest"> <correlations><correlationinitiate="no"set="CorrelationByDeck"/></correlations> <sequence> <assign> <copy> <from> <literal> <pickSpadeResponsexmlns="http://www.stark.com/PickService"><Deck/></pickSpadeResponse> </literal> </from> <tovariable="spadeResponse"part="parameters"/> </copy> <copy> <from>bpel:getVariableProperty("spadeRequest", "srvns:deck")</from> <to>$spadeResponse.parameters/srvns:Deck</to> </copy> </assign> <replyoperation="pickSpade"partnerLink="IncomingLink"variable="spadeResponse"/> </sequence> </onMessage>