BizTalk Messaging Archive Custom Solution
Lately one of the questions asked on
BizTalk Server Forums
intrigued me. The question was how one could archive a message including its message context.
Archiving received message
As soon as a message reaches BizTalk it can go through one of the
default pipelines
(XMLReceive,PassThruReceive) and a message context is added to incoming message.
The
XMLReceive
pipeline has a
XmlDisassembler pipeline component
on the disassembling stage.
Whenever an Xml message is received via the XmlReceive pipeline the
XmlDisassembler
will do the following tasks:
Promote the "MessageType" context property by taking the combination of
TargetNamespace
and
Root Element
in the format of: Targetnamespace#RootElement. So one of context properties BizTalk will set (promote) is the MessageType.
Name:
MessageType -
Namespace:
http://schemas.microsoft.com/BizTalk/2003/system-properties
-
http://BizTalk.Archiving.BankTransaction#Transaction
Remove Envelopes and disassemble the interchanges
Promote the content properties from interchange and individual document into message context based on the configured distinguished fields and promoted properties.
I will discuss here a custom disassembler pipeline component that will promote the “MessageType” context property and archive the message context and body to file. It will not perform the other two default actions by
XmlDisassembler pipeline component.
Pipeline component is targeted for
disassembler
stage of the receive pipeline. The component category is CATID_DisassemblingParser will be set above the class amongst other attributes. Since the component is targeted at the disassembling stage the
IDisassemblerComponent
needs to be implemented. This interface has two methods,
Disassemble
and
GetNext
. In the
Disassemble
method you will find the implementation for archiving the received message.
///
/// Implemen