BizTalk works under publish/subscriber architecture. The node which wants to communicate with other node using BizTalk will first publish their message in the database. BizTalk will then subscribe this message based on some rules and routed to proper endpoint.
In BizTalk, publishing means XML message gets entered in the messagebox
database (MsgDB
which we will see later) and subscription means a set of rules which are used to get the proper message from the database.
Routing of message from one endpoint to another using subscription is known as content based routing.
Every message in BizTalk is an XML message which contains context properties of the message.The message context includes all the instance-specific and exchange-specific data fields. It also contains the message metadata that the messaging engine of BizTalk used for subscription and routing of messages.
Few terminology used while interacting with BizTalk:
- Message: Message is basically an XML file which gets routed from one location to another. BizTalk process messages are based on business logic implemented by developer.
- Message Type: namespace#rootnode used to uniquely identify a message
- Typed Message: Message adheres to a particular schema.
- UnTyped Message: Message adheres to
System.Xml.XmlDocument
- Message Context: Message metadata used by BizTalk to process messages.
- Context Properties: Key/Value pair of properties stores in Message metadata.
- Promoted properties: Message fields marked as promoted are stored in message metadata and used for routing messages.
- Distinguished properties: Message fields marked as distinguished property are visible only within orchestration and are not used for routing messages.
- CBR (Content Based Routing): Routing messages based on subscription to the proper endpoint is known as CBR.
- Ports and Adapters: They provide the logical abstraction for sending and receiving message to and from BizTalk.
Frequently Asked Questions
1. What are the two types of subscription? What is the difference?
Ans. There are two types of subscription: activation and instance. An activation subscription is one specifying that a message that fulfills the subscription should activate or create a new instance of the subscriber when it is received. An instance subscription indicates that messages that fulfill the subscription should be routed to an already-running instance of the subscriber. When an orchestration instance or receive port completes processing, instance subscriptions are removed from the message box while activation remains active as long as the orchestration or send port is enlisted.
2. What is MessageAgent(MA)?
Ans. The Messaging layer provides a layer of abstraction over the messagebox
database. It uses the .NET com interlop to expose a set of API that BizTalk core engine used to communicate with messagebox. MA communicates with messagebox and will find subscribers that will be interested in consuming the message.
3. Why do some artifacts in BizTalk have start/stop option while some artifacts have enable/disable option?
Ans. In BizTalk, the publishers have enable/disable option, i.e., they can publish message into MessageBox
and the subscriber in start/stop option (subscribers are those which take messages from MessageBox
based on subscription rule).
4. How many types of schema in BizTalk?
Ans. Document Schema, Flat-File Schema, Envelop Schema and Property Schema.
5. Difference between Distinguished field and Promoted field?
Ans. In BizTalk, a schema node can be marked as distinguished or promoted by right clicking on it. Distinguished field is visible within orchestration and promoted field is visible throughout the BizTalk process. Distinguished field is used to get the node value and manipulate/do-calculation on that value. Promoted field is used for CBR (Content Based Routing).
Key Differences
- Distinguished fields are used only within single orchestration instance and are not being accessed by other BizTalk objects.
- Distinguished fields are of any length as opposed to promoted field (max 255 length)
- Distinguished fields are not persisted in the database as they are only the xpath of the nodes in the XML.
6. What is Message Context?
Ans. Message Context is the metadata of BizTalk message which contains instance specific as well as exchange specific data. For instance specific data (data coming from message), the nodes are needed to be promoted. Once promoted, the BizTalk publish-subscribe architecture will create subscription based on the promoted properties and send it to the respective artifact.
7. Why messages are immutable in BizTalk?
Ans. In BizTalk , once the messages are submitted into MessageBox
DB, it will not allow to change the content of message. This is to mitigate the risk of subscription. Suppose if any orchestration or send port subscribes a message based on some field value of the message and some other BizTalk artifact changes the value, then things don’t work, i.e., publish/subscribe messaging failed. So, if you want to change the original message inside an orchestration, then use construct shape and create new message by copying the original message and change the values.