BizTalk Pipeline Custom Component Message Unzippper

Project in Code Gallery:


This Custom Pipeline Component for BizTalk Server 2010, receives a compressed message, unzips it and sends one message per each file that the compressed file as in it. Imagine the following scenario: you have ten files that you want to send to some destination, instead of sending ten messages (one per file) you can easily send one compressed file (with all the ten files in it), taking as only precaution  the insurance that the destination system as this component in its receive pipeline.

Building the Sample

After downloading the project folder, you just need to bild it and copy the DLL generated to C:\Program Files (x86)\Microsoft BizTalk Server 2010\Pipeline Components, after that Create a new BizTalk Server Empty Project, add a new Pipeline, go to your Pipeline toolbox, right click -> Choose Item -> Pipeline Componentes -> Check the option “DisUnzip”. Now drag this component to the Dissamble fase andadd a XML Disassembler right next to DisUnzip. Yourpipeline should look like this:

Unzip Method

The main method in this project has a very simple algorythm that you can check bellow:

public void Disassemble(Microsoft.BizTalk.Component.Interop.IPipelineContext pc
, Microsoft.BizTalk.Message.Interop.IBaseMessage inmsg)
            IBaseMessage Temp = inmsg;
            using (ZipFile zip = ZipFile.Read(inmsg.BodyPart.GetOriginalDataStream()))
                foreach (ZipEntry e in zip)
                    var ms = new MemoryStream();
                    IBaseMessage outMsg;
                    outMsg = pc.GetMessageFactory().CreateMessage();
                    outMsg.AddPart("Body", pc.GetMessageFactory().CreateMessagePart(), true);

                    string XMLMessage = Encoding.UTF8.GetString(ms.ToArray());

                    MemoryStream mstemp = new System.IO.MemoryStream(

                    outMsg.GetPart("Body").Data = mstemp;


Besides this method the dissambler component should Have the GetNext() method to enforce the pipeline to send each one of the messages that you enqueue in the Queue collection:

public Microsoft.BizTalk.Message.Interop.IBaseMessage
            GetNext(Microsoft.BizTalk.Component.Interop.IPipelineContext pc)

            // get the next message from the Queue and return it
            Microsoft.BizTalk.Message.Interop.IBaseMessage msg = null;
            if ((_msgs.Count > 0))
                msg = ((Microsoft.BizTalk.Message.Interop.IBaseMessage)(_msgs.Dequeue()));
            return msg;
Rui Machado | Microsoft Student Partner 2012
Devscope @ 2012

Deixe uma Resposta

Preencha os seus detalhes abaixo ou clique num ícone para iniciar sessão:

Logótipo da

Está a comentar usando a sua conta Terminar Sessão / Alterar )

Imagem do Twitter

Está a comentar usando a sua conta Twitter Terminar Sessão / Alterar )

Facebook photo

Está a comentar usando a sua conta Facebook Terminar Sessão / Alterar )

Google+ photo

Está a comentar usando a sua conta Google+ Terminar Sessão / Alterar )

Connecting to %s