A common scenario in a BizTalk solution is to subscribe to a message based on its content or context and make decisions based on the underlying values. This is known as content-based routing. In this article, I will cover the principles and techniques to expose this sort of metadata in BizTalk Server.
Principles of promoting properties
In order to publish metadata associated to a message in BizTalk, we need to promote some data fields of the message using the property schema mechanism. This task can be done using two approaches: quick promotion or regular promotion. In addition to data fields within the message, we can also promote system properties are automatically promoted in BizTalk. Any promoted properties (from the BizTalk system and from the messages also known as message context) are available for subscription by BizTalk objects such as send ports, send port groups and orchestrations.
You can use promoted properties as decision points and routing ways for the messages inside an orchestration, although this has an overhead because the whole message must be load to be interrogated. In order to gain in performance, we use in orchestrations another technique known as distinguished fields which are lighter.
To access a distinguished field, we create a reference to the name of the message, the name of the record structure and the name of the distinguished field with each named item separated by a period using the following syntax
MessageName.RecordName.ChieldRecordName.DistinguishedFieldName. Promoted properties are accessed by creating a reference to the name of the message, the name of the property schema and the name of the promoted property name using the following syntax MessageName(PropertySchemaName.PromotedPropertyName).
Getting started with an example
Now we're going to subscribe to a message based on the content of the message. We're going to use Property Schema items to promote the data fields in the message in order to set up filter expressions. We have to use any pipeline but PassThruReceive pipeline to create the message context during the pipeline processing. Once added to the message context, they can be used by send ports and other BizTalk subscribing items.
Open Visual Studio .NET and create an empty BizTalk project and add the Customer_Schema.xsd XSD Schema item (see Figure 1).
Then create the schema as shown in Figure 2.
Now let's promote the CustomerID data field by right-clicking and selecting Promote | Quick Promotion (see Figure 3).
Then you will be asked to add this data field to a property schema and in turn this new property schema is added to the project. To view all promoted properties, select any node of the schema and select Promote| Show Promotions option to open the Promote Properties windows (see Figure 4).
Build and deploy the solution.
Now we're going to configure the solution to route the messages concerning the underlying content. For example, if a messaging holding the value of the customer id is greater than or equal to 1 and less than 5, then it will be routed to a directory output1, and if the value of the customer id is greater than or equal to 5 and less than 10, it will be routed to the directory output2. In order to configure the solution, open the BizTalk Server 2006 Administration Console and navigate to the Messaging_Schemas node in the Applications sub-tree. Create a receive location to read the messages.
Now let's create and configure two send ports. See in Figure 5 the configuration for the Send Port number 1 and in the Figure 6 the configuration for the Send Port number 2.
In this article, I covered the principles and techniques to promote properties in BizTalk Server 2006 with an illustrative example that you can use as a baseline to apply it for your own situation.