แก้ไข

แชร์ผ่าน


Handling Incoming Data Streams in Pipeline Components

The following considerations should be made when writing custom disassembler code for pipeline components in BizTalk Server.

Do not close the incoming data stream in custom dissasember code

When you write custom disassembler code for pipeline components in BizTalk Server, ensure that you do not close the incoming data stream in the disassembler code. The incoming stream from the input message is a shared resource. The incoming stream is also used by the message body tracking component in the BizTalk Server message engine.

If you either implicitly or explicitly close the incoming stream, tracking data may be lost and you will be unable to examine the stream data using message event and service instance tracking in BizTalk Server.

Use the Seek method of the Stream class to set the data stream pointer to the start of the stream

Ensure that you read from the incoming data stream until the end of the stream is reached. For example, if custom code makes a read request for 300 KB of data and the code only receives 34 KB of data, do not assume that the end of the stream has been reached. The custom code should always read from the incoming stream until 0 bytes is returned.

Before returning the data stream in the custom component logic, set the data stream pointer back to the start of the stream. For example, this code illustrates logic to use the seek method to point to the beginning of the stream before returning the stream:

myDataStream.Seek(0, SeekOrigin.Begin);  
return myDataStream;  

If you do not do this and the stream is read to the end in the current component, the next component receives what appears to be an empty stream because the data stream pointer was not set to the start of the stream. This can cause unexpected parsing and validation errors in subsequent pipeline components.