This is the WSO2 Business Process Server documentation version 3.0.0.View documentation for the latest release.

Unknown macro: {next_previous_link3}
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

In this sample, we explore how to use correlation sets to route a message to an existing instance of a business process. We are going to use the simplest possible BPEL process. An Echo Process which accepts the same request message twice. The following is a sequence diagram for the sample scenario.

Since the second EchoRequest can either create a new instance of the EchoProcess or be routed to a previously created instance of EchoProcess, we require a correlation set.

Introducing CorrelationSet, Property and Property Alias

A CorrelationSet is a unique set of values contained in the message that is used by the process engine to select the correct process instance to send the message to. Correlation is done between two or more messages. A CorrelationSet can contain one or more properties.

Once we define a correlation property, we have to define the corresponding values in each of the messages we expect to correlate. These corresponding values are called Property Aliases.

Lets create the process using WSO2 Developer Studio:

Step1. Create the business process.

Click next and client finish to create the BPEL project.

2. Generate a business process with the synchronous business process template.

3. Drag and drop receive, assign and reply activities such that we will get the following process.

4. Click on the Assign activity and assign ‘input’ from input variable to ‘result’ from output variable.

5. Similarly, complete the next receive, assign and reply activity by using the same partner link ‘client’. Now we have completed the business of the process logic. Now we need to add the correlation set to two receive activities.

6. Create a correlation set by clicking on the ‘+’ sign next to Correlation Sets.

7. Select the correlation set and select properties and click on Add.

8. We will get the Select property wizard. Click on New.

9. Give a name to our correlation property.

10. Select the data type for our correlation property. We have selected is here as a ‘Simple Type’. Click Browse. Now we have to select the data type from xml schema types. Select string as our type.

Now a pop up box will appear and asks for the prefix to be used to the xml schema namespace. Give the prefix as ‘xsd’. 

11. Click on the new button next to Alias to define property alias.

12. Click on browse and select the message type and input string for query.

13. Now we have finished defining the correlation set, property and alias. Note that we have selected only one alias here because, we are using the same message for both receive activities. Now we have to add the correlation set to the receive activities. On the first receive activity, which creates the process instance, we will initialize the correlation set. On the next, receive activity; we do not need to initialize. Click on the receive activity, and go to properties, click add and select the correlation set. Since we have only one correlation set, it will appear. On the initialize section select yes.

On the next correlation activity, set initiation to no.

14. Next, generate the deployment descriptor.

Next select all files related to the project and create a zip package.  Upload the bpel package.  One the process is deployed successfully; we can use tryit to send a request to the process.

Now browse to instance view for this process. Now the instance has complete up to reply activity and is waiting on the next receive activity. Under the correlation properties: you can see the value we sent in the request.

14. Now send the same request from tryit again.  Now the process instance has gone to the completed instance.  You can follow the same steps we used here to add correlation sets to any asynchronous business process you implement. Correlation sets can be added to ‘receive’, ‘invoke’ and ‘pick’ activities.

  • No labels