BizTalk Custom pipeline component - How do I add sequence number to debatched messages

181 views Asked by At

Have to split messages based on tag identifier. In addition would like to add sequence number of each message after split. Spitting is working but not sure how to add sequence

Code:

   public new void Disassemble(IPipelineContext pContext, IBaseMessage pInMsg)
    {
        IBaseMessage Temp = pInMsg;

        IBaseMessage outMsg;

        string msg = MessageToString(pInMsg);

        string[] msgs = msg.Split(new string[] { FlatFileTagSplitterSplitTag }, StringSplitOptions.None);


        foreach (string tmpstr in msgs)
        {

            if (tmpstr.Trim() != "")
            {

                outMsg = pContext.GetMessageFactory().CreateMessage();
                outMsg.AddPart("Body", pContext.GetMessageFactory().CreateMessagePart(), true);
                outMsg.Context = pInMsg.Context;
                outMsg.Context = 

                MemoryStream msOut = new MemoryStream();
                byte[] bts = System.Text.Encoding.GetEncoding(FlatFileTagSplitterDataEncoding).GetBytes(FlatFileTagSplitterSplitTag + tmpstr);
                msOut.Seek(0, SeekOrigin.Begin);
                msOut.Write(bts, 0, bts.Length);
                msOut.Position = 0;
                outMsg.BodyPart.Data = msOut;
                long i = outMsg.BodyPart.Data.Length; //Crazy hack
                base.Disassemble(pContext, outMsg);
                IBaseMessage outboundMessage = null;
                while ((outboundMessage = base.GetNext(pContext)) != null)
                    outMsg.Context
                    qOutputMsgs.Enqueue(outboundMessage);
            }

        }



    }
0

There are 0 answers