Custom Dissasembler Pipeline Component – Stream issue?

Home Page › Forums › BizTalk 2004 – BizTalk 2010 › Custom Dissasembler Pipeline Component – Stream issue?

Viewing 0 reply threads
  • Author
    Posts
    • #24274

      Hi,
      Having problems with a custom flatfile
      dissasenbler pipeline component (per instance pipeline) where 19
      receive locations utilies this component and ocassionaly we get “The
      remaining stream has unrecognizable data” error. The funny thing is
      that the file can be resumed and if file is saved from BTS Admin and
      run again it works fine. No missing linefeeds or something like that.
      We
      fetch data from an FTP folder and move the files to an intermediate
      file share where the 19 receive locations picks up the files. The
      output from the component to messagebox is two messages. One for
      archiveing origina data and one message that is manipulated (filter
      unwanted rows), Code for review.  Guess we’ve done
      something really stupid with are way to handle streams and we’re stuck.
      Please assist.

       

      Code:

      public void Disassemble(IPipelineContext pContext, Microsoft.BizTalk.Message.Interop.IBaseMessage pInMsg)
             
      {

               
               
                  msgPart
      = pInMsg.BodyPart;
                 
      Stream originalStream = pInMsg.BodyPart.GetOriginalDataStream();
                 
      string inboundTransLocation = string.Empty;
                 
      string inboundFileName = string.Empty;
                  inboundFileName
      = this.GetFileReceiveName(pInMsg);
                 
                 
      //Create message for archiving sent to messagebox for later subsciption and sending
                 
      //to desired repository
                 
      ArchiveMessage = pContext.GetMessageFactory().CreateMessage();
                 
      ArchiveMessage.AddPart("Body", pContext.GetMessageFactory().CreateMessagePart(), true);
                 
      ArchiveMessage.Context.Promote(propertyName, systemPropertiesNamespace, messageType);
                 
      ArchiveMessage.Context.Write("ReceivedFileName", "http://schemas.microsoft.com/BizTalk/2003/file-properties", inboundFileName);
                 
      ArchiveMessage.BodyPart.Data = CreateBodyPartData(pInMsg, inboundFileName);
               
                       
      StringBuilder originalStrBuilder = new StringBuilder();
                 
      StreamReader streamReader = new StreamReader(originalStream, System.Text.Encoding.Default);
                 
      while (!streamReader.EndOfStream)
                 
      {
                      originalStrBuilder
      .Append(streamReader.ReadLine()+System.Environment.NewLine);
                     
                 
      }

                  streamReader
      = null;
                 

                 
      # region manipulate original message
                 
      // Manipulate the origninal message
                 
      string strMsg = originalStrBuilder.ToString();
               
                 
                   data
      = HandleMessageGeneration.createFilteredMsg(strMsg, inboundFileName, ResubmitRcvLoc);
                 
                 
      #endregion
                 
      try
                 
      {
                     
      if (msgPart != null)
                     
      {
                         
      if (originalStream != null)
                         
      {
                             
      // do the disassembling
                             
      byte[] arrByte = ConvertToByteArray(data);
                              originalStream
      = (new MemoryStream(arrByte));
                             
      //archiveStream = (new MemoryStream(arrByte));
                         
      }
                     
      }
                 
      }
                 
      catch (Exception)
                 
      {
                     
      System.Diagnostics.Trace.WriteLine("Pipeline Disassemble Stage Exception");
                     
      throw;
                 
      }
                 
      if(originalStream.CanSeek)
                      originalStream
      .Seek(0, SeekOrigin.Begin);
                 
                  msgPart
      .Data = originalStream;

                 
      IBaseMessage outMsg = pInMsg;
                  outMsg
      .BodyPart.Data = originalStream;
                 
                  myFFDasmComp
      .Disassemble(pContext, outMsg);
                                             
                 
      #endregion

             
      }
             
             
      public Microsoft.BizTalk.Message.Interop.IBaseMessage GetNext(IPipelineContext pContext)
             
      {
               
                 
                             
      // !ResubmitRcvLoc (Pipeline property)  The message should not be archived again if resubmitted
                             
      //
                 
      if (!ResubmitRcvLoc && FirstCall == true)
                 
      {
                     
      FirstCall = false;
                     
      return ArchiveMessage;
                 
      }
                             
      // If we have hit one and message has one or more records (in addition to header info)
                             
      // it should be submitted to messagebox otherwise only archived.
                 
      if (HandleMessageGeneration.HasMatchingSubscriptions == true)
                     
      return myFFDasmComp.GetNext(pContext);
                 
      else
                     
      return null;
             
      }


Viewing 0 reply threads
  • The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.