The BPEL Service Engine runtime uses a mechanism called correlation to track the multiple, stateful, long-running exchanges of messages that typically take place between a BPEL process and its partner services. A message in such a conversation is mapped to a composite value made up of one or more properties defined in a WSDL file.
Thus, correlation sets are used to support stateful collaboration between web services in a standardized, implementation independent way. Correlation sets rely on the correlation data tokens stored in the message envelopes, headers, or business documents themselves. The declaration of correlation relies on the declarative properties of messages. A property is a field within a message identified by a query. Queries are specified by special constructs called property aliases.
The following terms apply to correlation:
Correlation sets can be defined for the Process element. The defined correlation sets are then used by message activities (Invoke, Reply, and Receive), which describe a conversation between a process and a partner service.
Correlation sets on Invoke activities are used to verify that outbound messages contain data that is consistent with the data found within specified correlation set instances.
Correlation set names are also used in the onMessage branches of Pick elements.
Follow these four basic steps to enable correlation in a process:
When a correlation set is defined, it has name and property attributes. A correlation set within a synchronous Invoke activity has an additional attribute: pattern. This attribute specifies whether the correlation set applies to the request message, the response message, or both.
The initiate attribute indicates whether the correlation set is to be initiated with the message's property values. When the initiate attribute has the value Yes, the correlation set is initiated with the values of the properties found in the message. If an initiate attribute is missing, it has the default value No. The fault bpws:correlationViolation is thrown if an activity with initiate=No tries to use a correlation set that has not been initiated before. When the initiate attribute has the value Join, the activity must attempt to initiate the correlation set, if it has not yet been initiated.