Share via

Custom Pipeline- handler- XML Disassembler failed to recognize data

jacks pm4ms 1 Reputation point
2022-07-21T11:02:33.927+00:00

Hello Community,

Issue: I am stuck with having my custom receive pipeline component, working as needed. when tested, it fails stating no disassembler stage can recognize the data.

Objective:

  1. goal is to place the incoming xml file to a different target folder if it exceeds the threshold file size, finish the execution as no other stages are needed to be executed in this case. and,
  2. process it/send it to next stage if the incoming file is within or less than the threshold (value. no manipulation of data is needed). Threshold in bytes is set in the pipeline property.

I have placed the component in the decoder stage,

  • it is able to handle the file if it exceeds the threshold size and places it to a target folder set in property successfully.

. however, when the files size is within the limit, it reaches to default xml disassembler stage and fails with Receive pipeline failed to execute: "no disassembler stage can recognize the data"

Options tried:

  1. Allow unrecognized message property set to true - Trues - no luck still the same error.
  2. Set the Docspec name in disassembler property - still the same error.

I suspect, it could be an issue with else condition in execute method, or the IF condition itself has something wrong. please help if there is anything can be modified.
Disassembler stage doesn't seem to be getting the appropriate value to process further. (I would expect it to fail after the disassembler stage but it isn't passing this stage.)

Here is the code in execute method:

public IBaseMessage Execute(IPipelineContext pContext, IBaseMessage pInMsg)
{

        try  
        {  

            Stream sourceFileStream = pInMsg.BodyPart.Data;  
            string sourceUri = Convert.ToString(pInMsg.Context.Read(PROPERTYNAME_RFN, FILEPROPNAMESPACE));  


            if (TargetFolderPath == null || TargetFolderPath.Length == 0 || FileSizeThreshold == 0 || FileName.Length == 0)  
            {  
                pInMsg.BodyPart.Data.Position = 0;  
                return pInMsg;  
            }  

                //FileName format  
                string date = DateTime.Now.ToString("yyyy.MM.dd");  
                string time = DateTime.Now.ToString("hh.mm.ss");  
                string DT = "_" + date + "_" + time + "_{" + Guid.NewGuid() + "}";  
                FileName = FileName + DT + FileExtension;  


                //Get size of the source file (in bytes)  

                long InputFileSize = new System.IO.FileInfo(sourceUri).Length;  

            //Create file in target folder if the size of Input file exceeds the FileSizeThreshold  


            if (InputFileSize > FileSizeThreshold)  

            {  
                TargetFolderPath = TargetFolderPath + "\\" + FileName;  
                CreateFile(TargetFolderPath, sourceFileStream);  
                System.Diagnostics.EventLog eventLog = new System.Diagnostics.EventLog("Application");  
                eventLog.Source = "BizTalk Server";  
                eventLog.WriteEntry("Large input file exceeding threshold is moved to " + TargetFolderPath, EventLogEntryType.Warning);  

                return null;  

            }  

            else  

            {  

                IBaseMessagePart bodyPart = pInMsg.BodyPart;  
                VirtualStream inputStream = new VirtualStream(bodyPart.GetOriginalDataStream());  
                StreamReader sr = new StreamReader(inputStream);  

                // Write ouput stream  
                VirtualStream outputStream = new VirtualStream();  

                StreamWriter streamWriter = new StreamWriter(outputStream);  

                streamWriter.Write(sourceFileStream);  
                streamWriter.Flush();  

                //  Reset position for next pipeline>  
                outputStream.Seek(0, SeekOrigin.Begin);  

                // Assign the output stream to the message  
                sourceFileStream = outputStream;  

                //  Add to resource tracker to avoid GC  
                pContext.ResourceTracker.AddResource(streamWriter);  

                  

            }  
              

        }  

            catch (Exception ex)  
            {  
                if (pInMsg != null)  
                {  
                    pInMsg.SetErrorInfo(ex);  
                }  
                throw ex;  
            }  

        return pInMsg;  

    }  

Many thanks in advance!

BizTalk Server
BizTalk Server

A family of Microsoft server products that support large-scale implementation management of enterprise application integration processes.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.