This blog is to explain about BizTalk Correlations.
What is Correlation?
Correlations can be defined as binding incoming messages with the appropriate instance of an orchestration.
Sample Scenario for Correlations:
My Orchestration has to send a request message to a Message Queue, let’s say it is “Input Queue”. Some other process takes the input message from “Input Queue” and after processing, output will be sent to another Queue, let’s say it is “Output Queue”.
Now Orchestration has to receive the message from Output Queue.
Also, my orchestration has to make sure that, it is consuming the output message of the of the correct instance.
How to Implement Correlations:
If we need to implement correlations, both input and output messages should have a common field element. For Example
Also, common element (CustId) should be property promoted.
Go to Orchestration View–>Types–>right click on Correlation Types–>Select New Correlation Type–>Correlation Properties windows appears with two panels.
Left Side Panel is “Available Properties” and the right-side panel is “Properties to correlate on:”
We need to select our property promoted field from left side panel and click on “ADD”, then field will be added to right-side panel. Using this common field, we will correlate request and response messages in the orchestration.
So far, we have created a Correlation Type.
Now we need to create a Correlation Set, which will be used in Orchestration Receive and Send shape properties.
Go to Orchestration View–>right click on Correlation Sets–>Select New Correlation Set->One Correlation set will be created.
Correlation Set properties–>you need to select correlation type which we have created above.
Now we are ready with correlation Sets.
In orchestration, if we want to send the message out, it will be through send shape. In send shape properties, we need to provide the “Initializing Correlation Set” property and select the correlation set which you have created in above steps.
Similarly, we need to provide “Follow Correlation Set” property in Receive shape which will be used to receive the response message. “Activate” property should be false in this second receive shape of the orchestration.
When you initialize the correlation set, one subscription id will be created for your instance in the message box and when you follow the same correlation set, using the subscription id, correct message will be received for that instance. This mechanism will be taken care by the BizTalk engine internally.
Here is the sample Orchestration view for Correlations demo.