Happy to introduce my first guest blog author: Peter Vervoorn from Virtual Green. Peter is a very experienced integration specialist. He has been working in ICT since 1995 and was a co-founder of Axon Olympus (now part of the Codit Group). Until his sabbatical in 2014 he headed the team of consultants at Axon Olympus as Technical Director. During his sabbatical in Thailand, he lost over 50 kilos and currently, he divides his time between Thailand and The Netherlands. He is a specialist with (Microsoft) Integration Tools and Technologies like BizTalk Server, Windows 10 IoT, Node-RED and is also involved in developing industrial automation prototypes.
Peter reach me with this funny, a bit unusual but quite interesting scenario: Calling multiple Disassemblers in a Receive pipeline, and I challenge him to be my first guest blog author on my blog. Challenge that he gladly accepted.
Situation
You receive a zip file, containing several files to extract. The extracted files should be disassembled too. (Possibly because they are in flat file format, or you want to call the XmlDisassembler to set the message type.)
Problem
Although the disassemble stage in the receive pipeline can contain multiple components, only the first component (matching the message) will be executed.
Solution
Create a new disassembler component, which will handle calling the sequential disassembler components.
The implementation of the Disassemble method is very easy, just call the initial component in the sequence.
The GetNext method is where it becomes a bit more interesting. Here we would have to extract all the messages from the first stage and feed them to the second stage. Note that it is not possible to create a single instance for the second stage and keep feeding it messages; each message requires its own instance of the component.
To do this, we have to create a new instance of the second stage component. Then we set the required properties (e.g., with values from the property bag.) Then we call the Disassemble method on the component. Next, we call GetNext to retrieve all messages and queue them.
The remainder of the implementation is to dequeening the messages.
Code
In the sample code below, all the usual methods (Load, Save, Validate, etc.) are not shown. Only the two relevant methods are shown. Also, all the plumbing has been removed for brevity/clarity.
[ComponentCategory(CategoryTypes.CATID_PipelineComponent)] [ComponentCategory(CategoryTypes.CATID_DisassemblingParser)] [System.Runtime.InteropServices.Guid("YOUR-GUID-HERE")] public class MultiDisassembler : IBaseComponent, IPersistPropertyBag, IComponentUI, IDisassemblerComponent { private ExtractorComp extractPC = new ExtractorComp(); private Queue<IBaseMessage> messages = null; public void Disassemble(IPipelineContext pContext, IBaseMessage pInMsg) { extractPC.Disassemble(pContext, pInMsg); } public IBaseMessage GetNext(IPipelineContext pContext) { if (messages == null) { messages = new Queue<IBaseMessage>(); IBaseMessage msgS1 = null; while ((msgS1 = extractPC.GetNext(pContext)) != null) { XmlDasmComp xmlDasmPC = NewXmlDasmWithPropertiesSet(); xmlDasmPC.Disassemble(pContext, msgS1); IBaseMessage msgS2 = null; while ((msgS2 = xmlDasmPC.GetNext(pContext)) != null) { messages.Enqueue(msgS2); } } } if (messages.Count > 0) { return messages.Dequeue(); } return null; } //... //Missing Code }
Tips
- You can add more stages, as required;
- If necessary, you can inspect a message and choose to either enqueue it directly or use a different component to disassemble that message.
(An example would be a zip file containing a mix of XML files and nested zip files) - In the above sample, all messages are queued when the GetNext method is called the first time. Another possibility is getting the next message in a just-in-time fashion. This requires a bit of additional work as you have to do additional housekeeping and handle possible empty messages.
- Often you see a disassembler also implementing IComponent. This is not required if only the DisassemblingParser attribute is set.
Download
THIS SAMPLE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND.
BizTalk Server Recipe: Calling multiple Disassemblers in a Receive pipeline (2 KB)
Microsoft | TechNet Gallery
BizTalk Pipeline Components Extensions Utility Pack
The pipeline component is available on BizTalk Pipeline Components Extensions Utility Pack project, that is a set of custom pipeline components (libraries) with several custom pipeline components that can be used in received and sent pipelines, which will provide an extension of BizTalk out-of-the-box pipeline capabilities.
The project is available on the BizTalk Server Open Source Community repository on GitHub (https://github.com/BizTalkCommunity), and everyone can contribute with new pipeline components that can be extended or improve the existing BizTalk Server capabilities.
Download
You can download BizTalk Pipeline Components Extensions Utility Pack from GitHub here:
BizTalk Pipeline Components Extensions Utility Pack
GitHub