Basics of Correlation in BizTalk
Introduction
In this blog, we will try to understand the basics of Correlation. In some cases, we would want the message to be correlated to another message in the message box and we can use correlation set and correlation Type to achieve this. Sometimes, it's not just about connecting messages. We may also need to attach additional properties to a message, such as a unique GUID or an application identifier, and promote these properties on to the context. We can also achieve this using Correlation Type and correlation set. Think of Correlation Type as a class, and Correlation Set as an instance of that Class.
Process Flow
Schema Creation
- Create an Order schema with a field called Order. Distinguish this field
- Create an Ack Schema with a field called Status
- Create a Property Schema with 4 fields and set the property base of the fields to "MessageContextPropertyBase":
ApplicationOrderApplication1Order1
Maps
- Create a map and name it "Order_TO_Ack". Source Schema should be Order schema and Target schema should be the Ack schema
- Status field is hard-coded to "Success".
Orchestration
- "ProcessOrder.odx" orchestration receives the order using a "specify later" port
- Extract the Order Number and assign it to a variable named "orderNo"
- Set the "applicationSystem" variable to "Oracle".
- Create correlation Type and name it "CorrelationType_Application_Order" and add the properties "Application" and "Order"
- Create Correlation set "Correlation_Application_Order" out of this correlation Type
- Create correlation Type and name it as "CorrelationType_Application1_Order1" and add the properties "Application1" and "Order1"
- Create Correlation set "Correlation_Application1_Order1" out of this correlation Type
- Message Assignment -
msgOrder is assigned to msgOrderFinal
Correlation Properties of Application, Order, Application1, Order1 are tagged to the message "msgOrderFinal" and assigned values.
- Initialize the correlation sets "Correlation_Application_Order" and "Correlation_Application1_Order1" and send the message to the message box for further consumption. This will help to promote these properties on to the context.
- "OracleProcessOrders" orchestration receives the message using "Application1" as filter
- Extract Application and Order from the context and assign them to respective variables
- Transform from Order to ACK message by running the map
- Tags the Ack message with a correlation set with properties of Application and Order by initializing the correlation set and sending it out to the message box. This will help to promote these properties on to the context.
- "ProcessOrder.odx" orchestration follows the correlation "Correlation_Application_Order" using receive shape and receives the Ack message. This basically connects the Order message instance to Ack message instance.
- Archives the Ack message
Bindings
Deployment
- Deploy the solution using Visual Studio
- Right-click on the solution and click on deploy solution
- Configure Bindings as described in the previous section
- Restart the host instances
- Refresh the admin console.
- Test the solution by dropping an order file on to the receive location
- If everything works fine you will see an ack message in the Send port file location
Code Files
https://drive.google.com/drive/folders/1tOvOoyHqdUXGeVQnYjKgLSuEkRM9oZj8?usp=sharing
Comments
Post a Comment